Why cookies dont expire after closing browser?

前端 未结 8 648
一整个雨季
一整个雨季 2020-12-14 22:31

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

相关标签:
8条回答
  • 2020-12-14 23:11

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

    0 讨论(0)
  • 2020-12-14 23:13

    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 讨论(0)
  • 2020-12-14 23:14

    To complete the answer:

    Sites identify users after closing the browser by using either

    • persistent cookies
    • flash cookies (LSOs)
    • ETags (http 1.1)
    0 讨论(0)
  • 2020-12-14 23:16

    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!

    0 讨论(0)
  • 2020-12-14 23:22

    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.

    0 讨论(0)
  • 2020-12-14 23:23

    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 讨论(0)
提交回复
热议问题