Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

cookie question

 
bernard savary
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a way to set the cookie to stay in the client forever i.e unless the user deletes it manually . I know the setMaxAge() take int arg in secs and also if we set to -1 then it lives as long the browser is instance is open. 0 deletes it . So any other way possible to set it to live forever ?
I know session.setMaxInactiveInterval(-ve num) will never timeout on the server . how about cookies on the clinet ?
 
swapna rao
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even i would like to know the answer for this question.i think this is implemnted in Javaranch site as this site cookie is stored in my system till i delete it explicitly.Even after closing the browser it will be available. How can we set the expiration date for cookie.
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Java you set the expiry date as an int of how many seconds it needs to live. If you specify Integer.MAX_VALUE it should last something like 68 years! (can someone check my math?)

Any time you start thinking you want a cookie to last forever, you should really consider storing that data in a database.
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Cookie API answers your other question. Look it up!

expiry - an integer specifying the maximum age of the cookie in seconds; if negative, means the cookie is not stored; if zero, deletes the cookie
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic