Forum Moderators: phranque

Message Too Old, No Replies

Are cookies refreshed when browser is refreshed?

         

dickbaker

11:27 pm on Oct 8, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This question just hit me today, and I haven't been able to find the answer. It's sort of like the "does the light stay on when the refrigerator door is closed" question.

Anyway, if you have cookies for a particular page in your browser already, are they renewed/refreshed when you refresh the page, or do the existing cookies just stay?

I didn't know which forum to ask this in, so I posted here.

lammert

3:04 am on Oct 9, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Cookies refresh depending on their time settings. Some cookies like the login cookie of WebmasterWorld reside on your computer for years and even survive when your browser is closed or the computer is restarted. Others have a lifetime just as long as the browser session is open.

As far as I have seen in my testing, cookies without a lifetime setting and which would therefore be killed once the browser is closed survive a page refresh. But cookies which have a short lifetime setting are refreshed if the page refresh takes place after the lifetime of the cookie has passed.

rocknbil

1:01 am on Oct 10, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Mostly correct, cookies without a valid expiration date/time (called session cookies) die when the browser is closed. But cookies with a valid expiration date/time (called persistent cookies) *may or may not* be refreshed, depending on the mechanism setting the cookie (server side programming or Javascript, examples.)

For example, a (poorly designed?) login scheme may set a cookie with a valid expiration date/time when you first log in, and never reset after that point. So let's say it's one hour in the future. As you navigate around the site, an hour later *poof* you have to log in again because the cookie expires.

Another (better designed?) login scheme would keep extending the hour out by resetting that cookie each time you navigate to another page - or refresh the page. So in this case, the answer would be yes, refreshing the page would "refresh" the cookie. It depends on how the site is coded.