What is the difference between Session Cookies and Persistent Cookies?

 Posted by Neeks on 3/21/2009 | Category: ASP.NET Interview questions | Views: 22141
Answer:

Persistent Cookies are same as Session Cookies except that, persistent cookies have an expiration date. The expiration date indicates to the browser that it should write the cookie to the client's hard drive
. Keep in mind that because a user can delete cookies from their machine that there is no guarantee that a cookie you "drop" on a user machine will be there the next time they visit your site.


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Posted by: Biswarup90 on: 2/8/2012 | Points: 10
There are two types of cookies, session cookies and persistent cookies. The key difference between the two is the time of expiration:

Session cookies expire at the end of the session. This means, when you close your browser window, the session cookie is deleted. This website only uses session cookies.
Persistent cookies do not expire at the end of the session.
A session cookie may be created when you visit a site or portion of a site. The cookie exists for the duration of your visit. For example, a session cookie is created when you use the Personal Login to access secured pages. Depending on the settings in your browser, you may have the option to deny the session cookie; however, if you deny the cookie you may have trouble using the site which relies on that cookie.

Session cookies are no longer accessible after one of the following events:

The user logs out of a site or a portion of a site
The user shuts down the browser
The session is inactive for a specified length of time
The user starts a new Internet session on the same computer

A persistent cookie is used to store your preferences for use by a single site. A persistent cookie is stored each time you visit the web site that sent the cookie.

Login to post response