Why does the cookie not expire after closing the browser?

Books and textbooks related to web programming say that cookies expire when the user closes the browser. Therefore, I cannot understand why, after closing the browser (Opera), I can see the list of my cookies in the "Options" window. And how are user sites (e.g. Facebook) after closing the browser (session cookies should end in accordance with books and textbooks)?

+6
source share
7 answers

Cookies have two different types:

  • session cookies stored in memory and expiring after exiting the browser
  • persistent cookies that have a lifetime are stored on disk and are sent by the browser before the timeout period has passed.

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

+21
source

There are two main types of cookies. Session and persistent cookies.

Session cookies are usually deleted when you close your browser. Session cookies are commonly used to track login information, shopping carts, etc.

Persistent cookies are also called tracking cookies. They are often used by advertisers to track the ads you've already viewed. It is also used for some web pages to remember information about you, for example, automatic registration and auto-completion of forms using commonly used details (for example, your username). Persistent cookies are deleted when the maximum age or expiration date is reached.

More information on the various types of cookies can be found on Wikipedia - HTTP cookie .

+5
source

Yes, session cookies expire at the end of a session, but this is not the only type of cookie. A cookie can have an expiration date that gives it a longer lifespan - a β€œpermanent” cookie.

+3
source

In some cases, it may seem that cookies do not end after the browser is closed, because in fact not all browser instances are closed.

There are a number of situations where a browser session may be running in the background after it seems to have been closed.

Browser error in IE, may leave a hidden session open. In Google Chrome, some extensions use "hidden pages" that persist after the browser closes. On a Mac, inexperienced users might think that they closed the browser by pressing the X button, but they neglected clicking Safari> Quit Safar or Command-Q.

This is especially true for using cookies to log in. This has become a problem for us with Sharepoint 2013 and ADFS. Hope this helps!

+2
source

To complete the answer:

Sites identify users after closing the browser using

  • persistent cookies
  • flash files (LSO)
  • ETags (http 1.1)
+1
source

Each cookie has an expiration time, if you do not set a specific value, it will accept the default value. The cookie expires only after this period has expired, regardless of whether you close the browser or not. You can kill the cookie by setting a negative value as the expiration time

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

0
source

This is because cookies are set to expire. It will not expire before the specified time, whether the browser is closed or not.

0
source

Source: https://habr.com/ru/post/906197/


All Articles