aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes cookie lifetime Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "cookie lifetime" Watch "cookie lifetime" New topic
Author

cookie lifetime

Dan Murphy
Ranch Hand

Joined: Mar 29, 2005
Posts: 126
Hi,

Can someone tell me what is the effect of
Does it mean:

(A) the cookie will expire when the browser is closed
(B) the cookie will never expire

If (A), then how do you make a cookie persist (indefinitely) on the client even after the browser has been closed?

Cheers,
Dan


SCJP, SCJD, SCWCD
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42631
    
  65
I'd think that the javadocs for that method make that rather clear, don't they?


Ping & DNS - my free Android networking tools app
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

Cookie class in JavaDoc


A good workman is known by his tools.
Dan Murphy
Ranch Hand

Joined: Mar 29, 2005
Posts: 126
I had a look at the specs, and while it answers my question about what happens when the age is set to -1 (cookie is deleted when browser exits), it doesn't answer my other question. That was: "is there any way to ensure that a cookie lives forever"?

Cheers,
Dan
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42631
    
  65
If the max age is an int, and negative ints won't work, then the maximum time a cookie can live is about 2^31-1 seconds. Not quite forever, but by then HTTP is most likely long forgotten
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: cookie lifetime