SlideShare uma empresa Scribd logo
1 de 20
PRESENTATION
ON
COOKIE AND SESSION
MANAGEMENT IN ASP .NET
Submitted To: Rachana Kamaliya
Prepared By: Kumbhani Minaxi
Limbasiya Jignasha
INDEX
 Introduction
 Overview of Session
 Session – Property/Method
 Session - Example
 Session Configuration
 Advantages And Disadvantages Of Session
 Overview Of Cookie
 How cookies Started?
 Cookie - Property
 Cookie – Example
 Advantages And Disadvantages Of Cookie
 Differences Between Session & Cookie
 References
jignasha & Minaxi
1
Session & Cookie
BASIC ABOUT STATE MANAGEMENT
 ASP.NET framework provides various ways to preserve
the states at various stage.
 controlstate, viewstate, cookies, session, etc.
 These can be defined at the client side and server side
state management
jignasha & Minaxi
3
Session & Cookie
STATE MANAGEMENT
jignasha & Minaxi
4
Session & Cookie
OVERVIEW OF SESSION
 Session is server side object.
 It is saving your data for the
session you are using the site.
 There is a time for which this
objects stay in the memory.
 Session is defined in
Web.Config for session state
section otherwise 20 mins by
default.
jignasha & Minaxi
5
Fig : For every client session
data store separately
Session & Cookie
SESSION
 The Session is active:
 Till the user closes the browser or
 A certain period expires (20 minutes )
 Every session is identified by a unique SessionID
 Created at first entry in the site
 Transmitted in a cookie by default
jignasha & Minaxi
6
Session & Cookie
PROPERTY
jignasha & Minaxi
7
Property Description
Count Gives the number of session variables which
are in memory.
Session ID Give you unique SessionID,which is assign to
your session.
TimeOut Get or Set TimeOut period.
IsNewSession A Boolean value specifies whether session is
new or old one.
IsCookieLess A Boolean value specifies whether session is
Cookless or not.
Keys A collection of all keys
Session & Cookie
METHOD
jignasha & Minaxi 8
Method Description
Session.Remove
(StrSessionName)
Remove an Item from session state
collection.
Session.RemoveAll() Remove all Items from session collection.
Session.Clear() There is no difference between clear and
RemoveAll().RemoveAll() calls
Clear().internally.
Session & Cookie
SESSION - EXAMPLE
 Session Declaration:
 Session Retriving:
 Session Removing:
 To handle events fired when a session is started or
ended we use Session_OnStart and Session_OnEnd in
the Global.asax file
jignasha & Minaxi
9
Session["username"] = "pesho";
string = Session["username"].ToString();
Session.Remove(“username");
or
Session[“username"] = null;
Session & Cookie
SESSION CONFIGURATION
 We can configure various aspects of the session
mechanism
 Use the sessionState section in Web.config
 Example:
jignasha & Minaxi
10
<system.web>
<sessionState
cookieless="true" mode="InProc"
timeout="60" cookieName="MySite" />
</system.web>
 To deny/restrict access to the session
<%@ Page EnableSessionState="False"%>
<%@ Page EnableSessionState="ReadOnly" %>
Session & Cookie
ADVANTAGES & DISADVANTAGES
Advantages:
 Session provide us the way of maintain user data
to all over the application.
 session is that we can store any kind of object in it.
:eg, database, dataset.. Etc
 Session is secure and transparent from the user.
Disadvantages:
 Performance overhead in case of large volumes of
user, because session data is stored in server memory.
jignasha & Minaxi
11
Session & Cookie
OVERVIEW OF COOKIES
 Cookies are the small files that are created on the
client's system or client browser memory.
 We can store small pieces of information in a client
system and use it when needed.
 It works transparently with the user.
 It can be easily used anywhere in your web application
jignasha & Minaxi
12
Session & Cookie
HOW COOKIE STARTED?
jignasha & Minaxi
13
Session & Cookie
HOW COOKIE STARTED?(CONT..)
jignasha & Minaxi
14
Session & Cookie
PROPERTY
Property Description
Name Specify name of cookie
Value Contains value of cookie
Expires Get or Set expiration Date of cookie.
Expired Informs you whether cookie is expired or not.
Domain Specific domain can be specified,if cookie
store in specific folder.
Path Allows you to set or get path of cookie to be
store.
jignasha & Minaxi 15
Session & Cookie
COOKIE - EXAMPLE
 working with cookies, we need to use the namespace
System.web.
 Creating a cookie that will be sent to the client Web
browser:
 Reading a cookie received at the server:
jignasha & Minaxi
16
HttpCookie cookie = new HttpCookie
("UserName", "bajivan");
Response.Cookies.Add(cookie);
HttpCookie cookie = Request.Cookies["UserName"];
Session & Cookie
ADVANTAGES & DISADVANTAGES
Advantages:
 It's very simple to use and implement.
 Browser takes care of sending the data.
 For multiple sites with cookies, the browser automatically
arranges them.
Disadvantages:
 It stores data in simple text format, so it's not secure at
all.
 There is a size limit for cookies data (4KB). .
 Most browsers provide limits the number of cookies is
20.
jignasha & Minaxi
17
Session & Cookie
1. Cookies can store only
"string" data type
2. They are stored at Client
side
3. Cookie is non-secure since
stored in text format at client
side
4. Only in few situations we
can use cookies because
of no security
1.Session can store any data
type
2. These are stored at Server
side
3. Session are secure because
it is stored in binary format
4. For all condition /situations
we can use sessions
jignasha & Minaxi
18
DIFF BETWEEN COOKIES & SESSION
Session & Cookie
REFERENCES
 http://www.codeproject.com
 http://en.wikipedia.org
 http://www.Tutorials.com
jignasha & Minaxi 19
Session & Cookie
20

Mais conteúdo relacionado

Mais procurados (20)

Java package
Java packageJava package
Java package
 
Unit 1 introduction to web programming
Unit 1 introduction to web programmingUnit 1 introduction to web programming
Unit 1 introduction to web programming
 
JDBC: java DataBase connectivity
JDBC: java DataBase connectivityJDBC: java DataBase connectivity
JDBC: java DataBase connectivity
 
Intent, Service and BroadcastReciver (2).ppt
Intent, Service and BroadcastReciver (2).pptIntent, Service and BroadcastReciver (2).ppt
Intent, Service and BroadcastReciver (2).ppt
 
Basics of Java
Basics of JavaBasics of Java
Basics of Java
 
PHP - Introduction to Object Oriented Programming with PHP
PHP -  Introduction to  Object Oriented Programming with PHPPHP -  Introduction to  Object Oriented Programming with PHP
PHP - Introduction to Object Oriented Programming with PHP
 
Php mysql ppt
Php mysql pptPhp mysql ppt
Php mysql ppt
 
Java script
Java scriptJava script
Java script
 
Presentation of bootstrap
Presentation of bootstrapPresentation of bootstrap
Presentation of bootstrap
 
Master page in Asp.net
Master page in Asp.netMaster page in Asp.net
Master page in Asp.net
 
Introduction to HTML5 Canvas
Introduction to HTML5 CanvasIntroduction to HTML5 Canvas
Introduction to HTML5 Canvas
 
Sessions and cookies
Sessions and cookiesSessions and cookies
Sessions and cookies
 
Oops in PHP
Oops in PHPOops in PHP
Oops in PHP
 
GRID VIEW PPT
GRID VIEW PPTGRID VIEW PPT
GRID VIEW PPT
 
PHP - Introduction to PHP Cookies and Sessions
PHP - Introduction to PHP Cookies and SessionsPHP - Introduction to PHP Cookies and Sessions
PHP - Introduction to PHP Cookies and Sessions
 
Java tutorial PPT
Java tutorial PPTJava tutorial PPT
Java tutorial PPT
 
Html forms
Html formsHtml forms
Html forms
 
Core java complete ppt(note)
Core java  complete  ppt(note)Core java  complete  ppt(note)
Core java complete ppt(note)
 
Java script
Java scriptJava script
Java script
 
JAVA AWT
JAVA AWTJAVA AWT
JAVA AWT
 

Destaque

Destaque (7)

Web Cookies
Web CookiesWeb Cookies
Web Cookies
 
Hypertext
HypertextHypertext
Hypertext
 
Presentation on Internet Cookies
Presentation on Internet CookiesPresentation on Internet Cookies
Presentation on Internet Cookies
 
Hypertext, hypermedia and multimedia
Hypertext, hypermedia and multimediaHypertext, hypermedia and multimedia
Hypertext, hypermedia and multimedia
 
Javascript
JavascriptJavascript
Javascript
 
Cookies PowerPoint
Cookies PowerPointCookies PowerPoint
Cookies PowerPoint
 
Cookies!
Cookies!Cookies!
Cookies!
 

Semelhante a Cookie & Session In ASP.NET

Php ssession - cookies -introduction
Php ssession - cookies -introductionPhp ssession - cookies -introduction
Php ssession - cookies -introductionProgrammer Blog
 
Session tracking in servlets
Session tracking in servletsSession tracking in servlets
Session tracking in servletsvishal choudhary
 
Cookies and Session
Cookies and SessionCookies and Session
Cookies and SessionKoraStats
 
murach12.pptx
murach12.pptxmurach12.pptx
murach12.pptxxiso
 
07 cookies
07 cookies07 cookies
07 cookiessnopteck
 
Cookies: HTTP state management mechanism
Cookies: HTTP state management mechanismCookies: HTTP state management mechanism
Cookies: HTTP state management mechanismJivan Nepali
 
Cookies in Angular | Install CookiesService
Cookies in Angular | Install CookiesServiceCookies in Angular | Install CookiesService
Cookies in Angular | Install CookiesServicePradeep Kumar
 
Lecture8 php page control by okello erick
Lecture8 php page control by okello erickLecture8 php page control by okello erick
Lecture8 php page control by okello erickokelloerick
 
Session and state management
Session and state managementSession and state management
Session and state managementPaneliya Prince
 
Cookies and sessions
Cookies and sessionsCookies and sessions
Cookies and sessionssalissal
 
SessionTrackServlets.pptx
SessionTrackServlets.pptxSessionTrackServlets.pptx
SessionTrackServlets.pptxRanjeet Reddy
 
ASP.Net Presentation Part3
ASP.Net Presentation Part3ASP.Net Presentation Part3
ASP.Net Presentation Part3Neeraj Mathur
 
C# cookieless session id and application state
C# cookieless session id and application stateC# cookieless session id and application state
C# cookieless session id and application stateMalav Patel
 
Jsp session tracking
Jsp   session trackingJsp   session tracking
Jsp session trackingrvarshneyp
 

Semelhante a Cookie & Session In ASP.NET (20)

Php ssession - cookies -introduction
Php ssession - cookies -introductionPhp ssession - cookies -introduction
Php ssession - cookies -introduction
 
Session tracking in servlets
Session tracking in servletsSession tracking in servlets
Session tracking in servlets
 
Cookies and Session
Cookies and SessionCookies and Session
Cookies and Session
 
murach12.pptx
murach12.pptxmurach12.pptx
murach12.pptx
 
07 cookies
07 cookies07 cookies
07 cookies
 
Sessions&cookies
Sessions&cookiesSessions&cookies
Sessions&cookies
 
Cache
CacheCache
Cache
 
Session tracking In Java
Session tracking In JavaSession tracking In Java
Session tracking In Java
 
Cookies: HTTP state management mechanism
Cookies: HTTP state management mechanismCookies: HTTP state management mechanism
Cookies: HTTP state management mechanism
 
Cookies in Angular | Install CookiesService
Cookies in Angular | Install CookiesServiceCookies in Angular | Install CookiesService
Cookies in Angular | Install CookiesService
 
FP512 Cookies sessions
FP512 Cookies sessionsFP512 Cookies sessions
FP512 Cookies sessions
 
Lecture8 php page control by okello erick
Lecture8 php page control by okello erickLecture8 php page control by okello erick
Lecture8 php page control by okello erick
 
Session and state management
Session and state managementSession and state management
Session and state management
 
Cookies and sessions
Cookies and sessionsCookies and sessions
Cookies and sessions
 
SessionTrackServlets.pptx
SessionTrackServlets.pptxSessionTrackServlets.pptx
SessionTrackServlets.pptx
 
ASP.Net Presentation Part3
ASP.Net Presentation Part3ASP.Net Presentation Part3
ASP.Net Presentation Part3
 
Sessions n cookies
Sessions n cookiesSessions n cookies
Sessions n cookies
 
Servlet session 10
Servlet   session 10Servlet   session 10
Servlet session 10
 
C# cookieless session id and application state
C# cookieless session id and application stateC# cookieless session id and application state
C# cookieless session id and application state
 
Jsp session tracking
Jsp   session trackingJsp   session tracking
Jsp session tracking
 

Último

Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxNikitaBankoti2
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 

Último (20)

Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 

Cookie & Session In ASP.NET

  • 1. PRESENTATION ON COOKIE AND SESSION MANAGEMENT IN ASP .NET Submitted To: Rachana Kamaliya Prepared By: Kumbhani Minaxi Limbasiya Jignasha
  • 2. INDEX  Introduction  Overview of Session  Session – Property/Method  Session - Example  Session Configuration  Advantages And Disadvantages Of Session  Overview Of Cookie  How cookies Started?  Cookie - Property  Cookie – Example  Advantages And Disadvantages Of Cookie  Differences Between Session & Cookie  References jignasha & Minaxi 1 Session & Cookie
  • 3. BASIC ABOUT STATE MANAGEMENT  ASP.NET framework provides various ways to preserve the states at various stage.  controlstate, viewstate, cookies, session, etc.  These can be defined at the client side and server side state management jignasha & Minaxi 3 Session & Cookie
  • 4. STATE MANAGEMENT jignasha & Minaxi 4 Session & Cookie
  • 5. OVERVIEW OF SESSION  Session is server side object.  It is saving your data for the session you are using the site.  There is a time for which this objects stay in the memory.  Session is defined in Web.Config for session state section otherwise 20 mins by default. jignasha & Minaxi 5 Fig : For every client session data store separately Session & Cookie
  • 6. SESSION  The Session is active:  Till the user closes the browser or  A certain period expires (20 minutes )  Every session is identified by a unique SessionID  Created at first entry in the site  Transmitted in a cookie by default jignasha & Minaxi 6 Session & Cookie
  • 7. PROPERTY jignasha & Minaxi 7 Property Description Count Gives the number of session variables which are in memory. Session ID Give you unique SessionID,which is assign to your session. TimeOut Get or Set TimeOut period. IsNewSession A Boolean value specifies whether session is new or old one. IsCookieLess A Boolean value specifies whether session is Cookless or not. Keys A collection of all keys Session & Cookie
  • 8. METHOD jignasha & Minaxi 8 Method Description Session.Remove (StrSessionName) Remove an Item from session state collection. Session.RemoveAll() Remove all Items from session collection. Session.Clear() There is no difference between clear and RemoveAll().RemoveAll() calls Clear().internally. Session & Cookie
  • 9. SESSION - EXAMPLE  Session Declaration:  Session Retriving:  Session Removing:  To handle events fired when a session is started or ended we use Session_OnStart and Session_OnEnd in the Global.asax file jignasha & Minaxi 9 Session["username"] = "pesho"; string = Session["username"].ToString(); Session.Remove(“username"); or Session[“username"] = null; Session & Cookie
  • 10. SESSION CONFIGURATION  We can configure various aspects of the session mechanism  Use the sessionState section in Web.config  Example: jignasha & Minaxi 10 <system.web> <sessionState cookieless="true" mode="InProc" timeout="60" cookieName="MySite" /> </system.web>  To deny/restrict access to the session <%@ Page EnableSessionState="False"%> <%@ Page EnableSessionState="ReadOnly" %> Session & Cookie
  • 11. ADVANTAGES & DISADVANTAGES Advantages:  Session provide us the way of maintain user data to all over the application.  session is that we can store any kind of object in it. :eg, database, dataset.. Etc  Session is secure and transparent from the user. Disadvantages:  Performance overhead in case of large volumes of user, because session data is stored in server memory. jignasha & Minaxi 11 Session & Cookie
  • 12. OVERVIEW OF COOKIES  Cookies are the small files that are created on the client's system or client browser memory.  We can store small pieces of information in a client system and use it when needed.  It works transparently with the user.  It can be easily used anywhere in your web application jignasha & Minaxi 12 Session & Cookie
  • 13. HOW COOKIE STARTED? jignasha & Minaxi 13 Session & Cookie
  • 14. HOW COOKIE STARTED?(CONT..) jignasha & Minaxi 14 Session & Cookie
  • 15. PROPERTY Property Description Name Specify name of cookie Value Contains value of cookie Expires Get or Set expiration Date of cookie. Expired Informs you whether cookie is expired or not. Domain Specific domain can be specified,if cookie store in specific folder. Path Allows you to set or get path of cookie to be store. jignasha & Minaxi 15 Session & Cookie
  • 16. COOKIE - EXAMPLE  working with cookies, we need to use the namespace System.web.  Creating a cookie that will be sent to the client Web browser:  Reading a cookie received at the server: jignasha & Minaxi 16 HttpCookie cookie = new HttpCookie ("UserName", "bajivan"); Response.Cookies.Add(cookie); HttpCookie cookie = Request.Cookies["UserName"]; Session & Cookie
  • 17. ADVANTAGES & DISADVANTAGES Advantages:  It's very simple to use and implement.  Browser takes care of sending the data.  For multiple sites with cookies, the browser automatically arranges them. Disadvantages:  It stores data in simple text format, so it's not secure at all.  There is a size limit for cookies data (4KB). .  Most browsers provide limits the number of cookies is 20. jignasha & Minaxi 17 Session & Cookie
  • 18. 1. Cookies can store only "string" data type 2. They are stored at Client side 3. Cookie is non-secure since stored in text format at client side 4. Only in few situations we can use cookies because of no security 1.Session can store any data type 2. These are stored at Server side 3. Session are secure because it is stored in binary format 4. For all condition /situations we can use sessions jignasha & Minaxi 18 DIFF BETWEEN COOKIES & SESSION Session & Cookie
  • 19. REFERENCES  http://www.codeproject.com  http://en.wikipedia.org  http://www.Tutorials.com jignasha & Minaxi 19 Session & Cookie
  • 20. 20