• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

cookie.getMaxAge

 
Jonny Andersson
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am playing with cookies. I create one and gives it one day of life using the call cookie.setMaxAge(24*60*60). But when I later on another page extracts it again from the cookies array using equals test for the name and asks for it�s MaxAge using the call cookie.getMaxAge() do I always get a -1 which indicates that the cookie will be removed when the session ends. I guess that I do something wrong somewhere but I have not been able to find what. The cookie is at least set and given proper life. I could verify that by a look at the Expires value for the cookie in my Firefox "Stored cookies list". It must therefore be in code where something is wrong. Do anyone have an immediate idea about what it can be? Do anyone know about any typical misstake that cause this problem?
 
Jonny Andersson
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, another try on this question ...

Have anyone at this forum ever been able to getMaxAge on a cookie extracted from the cookies-array in the request where the max-age is not -1?

When I create a cookie with the name userName, my name as value, and a max age 3600 seconds (or seconds for one day or whatever) do the COOKIE header (I picked it out in a try to find what it is wrong) in the request always look like:

userName=Jonny; JSESSIONID=30CFC9A24F10A161B1F2233B145A2FF0

And if I try to look at the age using getMaxAge is it always -1. The same is true for other cookies I have tried to set usig JavaScript. Could this be a bug in Tomcat? I have tried to search a litle for it. The result is the same both when I try with IE and Firefox.
 
Susanta Chatterjee
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I replied to both of your questions in Servlet forum.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic