IS there any way to set the maximumtime a cookie can be inactive in java? I am asking this because for the cookie class(in java docs) there is no method called setmaxinactiveinterval().
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Cookie class has a method setMaxAge, I hope that can be useful for you.
If that doesn’t work for you, You can store current time with cookie value and when you fetch it, just read and compare the stored time value and the time of reading the cookie, if the difference is more than the desired value. You can discard the cookie and treat it as an expired cookie.
However I strongly recommend using the Cookies’s setMaxAge() or similar method of Session class,