I am developing a java web application in which I have configured session-timeout to be equal to 4 minutes.This application also uses cookies.
My problem is after 4 minutes of inactivity the HttpSession expires but the cookies remain in the browser (age is set to -1). Is there any way to delete cookies after session timeout?
P.S. setting cookie age equal to 4 minutes wont help.cookies should be deleted after 4 minutes of inactivity .
解决方案
If you set the cookie age to 4 minutes, and reset the cookie age every time your server sends a response, then the cookie will time out after 4 minutes of inactivity.