Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello friends

i have requirement to expire cookie when browser is close and this can happen when we don't set expiration policy but I have also requirement to expire cookie withing in 20 minutes, If I apply expiration policy then browse close function will not work, I mean when I open browser again then cookie will be exist.

What I have to do to resolve this situation?
Posted

1 solution

If you set the Expires property of a cookie, then it stops being a Session Cookie, and gets stored at the remote system. At this point, the browser close will no longer affect the cookie validity.

If you always want "twenty minutes or browser close" which ever comes first, then don't set the Expires time, but store it in the cookie and check it manually. That way, it remains as a Session cookie and the browser closing and reopening will start a new session with no valid cookie loaded.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900