SlideShare a Scribd company logo
6
Most read
9
Most read
16
Most read
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

More Related Content

PPT
Cookies and sessions
Lena Petsenchuk
 
PPTX
Session bean
sandeep54552
 
PPTX
Distributed web based systems
Reza Gh
 
PPTX
PHP Cookies and Sessions
Nisa Soomro
 
PPTX
Introduction to EJB
Return on Intelligence
 
PPSX
Sessions and cookies
www.netgains.org
 
PDF
Enterprise java unit-3_chapter-1-jsp
sandeep54552
 
PDF
Introduction to HTML5
Gil Fink
 
Cookies and sessions
Lena Petsenchuk
 
Session bean
sandeep54552
 
Distributed web based systems
Reza Gh
 
PHP Cookies and Sessions
Nisa Soomro
 
Introduction to EJB
Return on Intelligence
 
Sessions and cookies
www.netgains.org
 
Enterprise java unit-3_chapter-1-jsp
sandeep54552
 
Introduction to HTML5
Gil Fink
 

What's hot (20)

PPT
jQuery Ajax
Anand Kumar Rajana
 
PPTX
Jdbc ppt
sandeep54552
 
PPT
Web Servers (ppt)
webhostingguy
 
PPTX
Java Server Pages(jsp)
Manisha Keim
 
PPTX
Caching
Nascenia IT
 
PDF
Model View Controller (MVC)
Javier Antonio Humarán Peñuñuri
 
PPTX
Css3
Deepak Mangal
 
PPTX
Cookies and sessions
Sukrit Gupta
 
PPTX
Jsp lifecycle
chauhankapil
 
PDF
JavaScript - Chapter 13 - Browser Object Model(BOM)
WebStackAcademy
 
PDF
Local Storage for Web Applications
Markku Laine
 
PPT
Clock synchronization in distributed system
Sunita Sahu
 
PPTX
Session tracking in servlets
vishal choudhary
 
PPT
Java Servlets
BG Java EE Course
 
PPT
System call
Sumant Diwakar
 
PPTX
Servlets
Akshay Ballarpure
 
PPTX
Cookies in servlets.ppt
Swetha S
 
jQuery Ajax
Anand Kumar Rajana
 
Jdbc ppt
sandeep54552
 
Web Servers (ppt)
webhostingguy
 
Java Server Pages(jsp)
Manisha Keim
 
Caching
Nascenia IT
 
Model View Controller (MVC)
Javier Antonio Humarán Peñuñuri
 
Cookies and sessions
Sukrit Gupta
 
Jsp lifecycle
chauhankapil
 
JavaScript - Chapter 13 - Browser Object Model(BOM)
WebStackAcademy
 
Local Storage for Web Applications
Markku Laine
 
Clock synchronization in distributed system
Sunita Sahu
 
Session tracking in servlets
vishal choudhary
 
Java Servlets
BG Java EE Course
 
System call
Sumant Diwakar
 
Cookies in servlets.ppt
Swetha S
 
Ad

Viewers also liked (7)

PPT
Web Cookies
apwebco
 
PPT
Hypertext
patrickalfredwaluchio
 
PPT
Presentation on Internet Cookies
Ritika Barethia
 
PPTX
Hypertext, hypermedia and multimedia
fernandadavalos2566
 
PPT
Javascript
guest03a6e6
 
PPTX
Cookies PowerPoint
emurfield
 
PPTX
Cookies!
kellimccabe
 
Web Cookies
apwebco
 
Presentation on Internet Cookies
Ritika Barethia
 
Hypertext, hypermedia and multimedia
fernandadavalos2566
 
Javascript
guest03a6e6
 
Cookies PowerPoint
emurfield
 
Cookies!
kellimccabe
 
Ad

Similar to Cookie & Session In ASP.NET (20)

PPTX
Sessions&cookies
Tirthika Bandi
 
PDF
Session and Cookies.pdf
HamnaGhani1
 
PPT
Session and state management
Paneliya Prince
 
PDF
state management asp.net
Pratiksha Srivastava
 
PPT
Session and cookies,get and post methods
baabtra.com - No. 1 supplier of quality freshers
 
PDF
ASP.NET-Web Programming - Sessions and Cookies
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Using cookies and sessions
Nuha Noor
 
PDF
Difference in session and cookie.pdf
g1tech
 
PPT
Synapse india dotnet development web approch part 2
Synapseindiappsdevelopment
 
PPTX
Session and cookies,get and post
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Chapter 8 part1
application developer
 
PPT
2310 b 14
Krazy Koder
 
PPTX
Cookies and Session
KoraStats
 
PPTX
75.pptx for all ki,nd of ajext file hear
hectortrading693
 
PPTX
COOKIES.pptx
18csjeyavarthini
 
PDF
Asp.net state management
priya Nithya
 
PPTX
Cookies: HTTP state management mechanism
Jivan Nepali
 
PPTX
Cookies
misbafatima
 
PPTX
FP512 Cookies sessions
Fatin Fatihayah
 
DOC
State management in asp
Ibrahim MH
 
Sessions&cookies
Tirthika Bandi
 
Session and Cookies.pdf
HamnaGhani1
 
Session and state management
Paneliya Prince
 
state management asp.net
Pratiksha Srivastava
 
Session and cookies,get and post methods
baabtra.com - No. 1 supplier of quality freshers
 
ASP.NET-Web Programming - Sessions and Cookies
baabtra.com - No. 1 supplier of quality freshers
 
Using cookies and sessions
Nuha Noor
 
Difference in session and cookie.pdf
g1tech
 
Synapse india dotnet development web approch part 2
Synapseindiappsdevelopment
 
Session and cookies,get and post
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 8 part1
application developer
 
2310 b 14
Krazy Koder
 
Cookies and Session
KoraStats
 
75.pptx for all ki,nd of ajext file hear
hectortrading693
 
COOKIES.pptx
18csjeyavarthini
 
Asp.net state management
priya Nithya
 
Cookies: HTTP state management mechanism
Jivan Nepali
 
Cookies
misbafatima
 
FP512 Cookies sessions
Fatin Fatihayah
 
State management in asp
Ibrahim MH
 

Recently uploaded (20)

PPTX
Cleaning Validation Ppt Pharmaceutical validation
Ms. Ashatai Patil
 
DOCX
Unit 5: Speech-language and swallowing disorders
JELLA VISHNU DURGA PRASAD
 
PPTX
Continental Accounting in Odoo 18 - Odoo Slides
Celine George
 
PPTX
How to Track Skills & Contracts Using Odoo 18 Employee
Celine George
 
PPTX
Applications of matrices In Real Life_20250724_091307_0000.pptx
gehlotkrish03
 
PPTX
Artificial Intelligence in Gastroentrology: Advancements and Future Presprec...
AyanHossain
 
PDF
Health-The-Ultimate-Treasure (1).pdf/8th class science curiosity /samyans edu...
Sandeep Swamy
 
PPTX
How to Apply for a Job From Odoo 18 Website
Celine George
 
PPTX
Five Point Someone – Chetan Bhagat | Book Summary & Analysis by Bhupesh Kushwaha
Bhupesh Kushwaha
 
PPTX
CONCEPT OF CHILD CARE. pptx
AneetaSharma15
 
PPTX
20250924 Navigating the Future: How to tell the difference between an emergen...
McGuinness Institute
 
PPTX
Artificial-Intelligence-in-Drug-Discovery by R D Jawarkar.pptx
Rahul Jawarkar
 
PDF
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
Nguyen Thanh Tu Collection
 
DOCX
SAROCES Action-Plan FOR ARAL PROGRAM IN DEPED
Levenmartlacuna1
 
PPTX
CDH. pptx
AneetaSharma15
 
PPTX
Measures_of_location_-_Averages_and__percentiles_by_DR SURYA K.pptx
Surya Ganesh
 
PPTX
Command Palatte in Odoo 18.1 Spreadsheet - Odoo Slides
Celine George
 
PPTX
BASICS IN COMPUTER APPLICATIONS - UNIT I
suganthim28
 
PPTX
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
PDF
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
Cleaning Validation Ppt Pharmaceutical validation
Ms. Ashatai Patil
 
Unit 5: Speech-language and swallowing disorders
JELLA VISHNU DURGA PRASAD
 
Continental Accounting in Odoo 18 - Odoo Slides
Celine George
 
How to Track Skills & Contracts Using Odoo 18 Employee
Celine George
 
Applications of matrices In Real Life_20250724_091307_0000.pptx
gehlotkrish03
 
Artificial Intelligence in Gastroentrology: Advancements and Future Presprec...
AyanHossain
 
Health-The-Ultimate-Treasure (1).pdf/8th class science curiosity /samyans edu...
Sandeep Swamy
 
How to Apply for a Job From Odoo 18 Website
Celine George
 
Five Point Someone – Chetan Bhagat | Book Summary & Analysis by Bhupesh Kushwaha
Bhupesh Kushwaha
 
CONCEPT OF CHILD CARE. pptx
AneetaSharma15
 
20250924 Navigating the Future: How to tell the difference between an emergen...
McGuinness Institute
 
Artificial-Intelligence-in-Drug-Discovery by R D Jawarkar.pptx
Rahul Jawarkar
 
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
Nguyen Thanh Tu Collection
 
SAROCES Action-Plan FOR ARAL PROGRAM IN DEPED
Levenmartlacuna1
 
CDH. pptx
AneetaSharma15
 
Measures_of_location_-_Averages_and__percentiles_by_DR SURYA K.pptx
Surya Ganesh
 
Command Palatte in Odoo 18.1 Spreadsheet - Odoo Slides
Celine George
 
BASICS IN COMPUTER APPLICATIONS - UNIT I
suganthim28
 
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 

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