15

In books and tutorials related with Web-programming written that cookies expire when user close browser. So I cant understand why after closing browser(Opera) I can see the list of my cookies in "Parameters" window. And how sites (for example Facebook) identifier users after closing browser (session cookies must expire according to books and tutorials)?

9 Answers 9

33

Cookies are of two different types:

  • session cookies, held in memory, and which expire once the browser exits
  • persistent cookies, which have a time-to-live, are persisted on disk, and are sent by the browser until their time-to-live has elapsed.

Read http://en.wikipedia.org/wiki/HTTP_cookie

1
  • 6
    what does closing the browser means? These days the browser is always open, you can close a browser tab, or a browser window, that still doesn't expire the cookie
    – filype
    Sep 5, 2016 at 18:41
10

There are two major kinds of cookies. Session and Persistent cookies.

Session cookies are usually removed when you close the browser. Session cookies are usually used for keeping track of login information, shopping carts etc.

Persistent cookies are also called tracking cookies. They are often used by advertisers to track what ads you have already watched. It is also used for some web pages to remember information about you, such as automatic login and auto-filling forms with commonly used details (such as your login name). Persistent cookies are removed when max age or expiration date have been reached.

More information regarding different cookie types can be found on Wikipedia - HTTP cookie.

5

Yes, session cookies expire at the end of the session - but this is not the only type of cookie. A cookie can have an expiration date set giving it a longer lifetime - a "persistent" cookie.

4

In some cases, it may appear that cookies are not expiring after closing the browser because, in fact, not all browser instances are closed.

There are a number of situations in which a browser session may be still running in the background, after it appears to have been closed.

A browser crash in IE, could leave a hidden session open. In Google Chrome, some extensions use "hidden pages" that persist after closing the browser. On Mac, inexperienced users may think they have closed the browser by clicking X, but they neglect to click Safari > Quit Safar or Command-Q.

This is especially concerning when using cookies for login purposes. This has become an issue for us with Sharepoint 2013 and ADFS. Hope this helps!

1

To complete the answer:

Sites identify users after closing the browser by using either

  • persistent cookies
  • flash cookies (LSOs)
  • ETags (http 1.1)
1

I hear you Brother. Sad but the cold reality is ... Closing a browser does not mean closing a browser.

Closing a browser here means killing the process behind that browser brand along with ALL INSTANCES.

For that to happen, one of the following things must take place:

1) You either reboot down your computer

2) or you or your users long Press on the browser's icon on the system tray and then select QUIT OR CLOSE ALL WINDOWS options (depending on whether you're on a mac or on windows)

Practically speaking, I know this is not what you wanted to see and find out as the crux of the matter but it is what it is.

Even if there is no visible instances of the browser, the big boy is still in the memory and unless you FORCE QUIT that process, your cookie is still in the session.

This should not have been designed this way. Closing all instances should have been enough.

0

Every cookie have an expiry time ,if you have not set a particular value , it will accept the default value .A cookie will expire only after this expiry time , no matter whether you are closing browser or not . You can kill a cookie by setting negative value to as expiry time

In php you have a good tutorial here http://php.net/manual/en/function.setcookie.php

0

Its because the cookies are set with expiry time. It will not expire until the specified time whether the browser closed or not.

0

It might be because of your browser settings if you're using Chrome or Firefox, so if you've configured your browser to "Continue where you left off" at startup, it won't delete those session cookies, this is the same in Firefox as well.

enter image description here

I actually took this answer from this question (which I couldn't find by google search, because it's specific to PHP, but I accidentally found it on google images!)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.