Is cookie expiration related to server expiration time?

We set cookies using the code below,

document.cookie = name+"="+value+ ";expires="+"domain=xyz.com;path=/";

And the session end time set on my server is 15 minutes. If the client is idle for 15 minutes, after 15 minutes the session will be destroyed. Will this destroy the value set in my cookie?

I mean, is the cookie expired in document.cookie related to the expiration of the cookie set on the server?

+4
source share
2 answers

I think the answer really depends on how the browser handles the cookie outputs .

When the server sends an HTTP response, the client (browser) will look for Set-Cookie headers for the response. If it is found, it will override the cookies stored in the browser.

Quote from Permanent HTTP client state cookie :

The expires header allows the client to know when it is safe to clear the mapping , but the client does not need to do this . The client may also delete the cookie before the expiration of the cookie if the number of cookies exceeds its internal limits.

Also check this out:

If the CGI script wants to delete the cookie, it can do this by returning the cookie with the same name and the time that has passed in the past will expire . The path and name must match exactly so that an expiring cookie replaces a valid cookie. This requirement makes it difficult for anyone other than the cookie maker to delete the cookie.

This means that if the web server automatically sends you a response with the Set-Cookie heading, it will override the cookie that you manually set.

Connected:
http://www.superuser.com/questions/356265/what-do-browsers-do-with-expired-cookies
http://www.stackoverflow.com/questions/1635909/how-do-i-remove-delete-expire-a-cookie-immediately

+1
source

If the cookie is destroyed, the data will also be destroyed.

0
source

All Articles