Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

cookie.getMaxAge

 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I replied to both of your questions in Servlet forum.
 
ice is for people that are not already cool. Chill with this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic