aspose file tools*
The moose likes Servlets and the fly likes Cookie Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Cookie Question" Watch "Cookie Question" New topic
Author

Cookie Question

Ashish Gauswami
Greenhorn

Joined: Aug 20, 2008
Posts: 22
how does websites like Amazon and Google remembers the users name forever?

if they use cookie then Cookie's setMaxAge method takes int argument and its in seconds. so the cookie will expire in few hours.


Ashish
SCWCD - Preparing, SCJP - 86%
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Originally posted by Ashish Gauswami:
so the cookie will expire in few hours.


How do you figure?
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4659
    
    5

Originally posted by Ashish Gauswami:how does websites like Amazon and Google remembers the users name forever?


Don't set an expiration time.

Reset it every time a user revisits.

If you forget when they have not returned within months, its no big deal
Ashish Gauswami
Greenhorn

Joined: Aug 20, 2008
Posts: 22
ok i guess i got it. in java Integer is four bytes which will come to 24855.134803240740740740740740741 days ((2^31-1)/(60*60*24)). which is good enough.

earlier i did wrong calculations.

Thanks for the reply.
Ashish Gauswami
Greenhorn

Joined: Aug 20, 2008
Posts: 22
Originally posted by Pat Farrell:


Don't set an expiration time.

Reset it every time a user revisits.

If you forget when they have not returned within months, its no big deal


if we will not set expiration time, the default is -1 which will only last for the browser session.
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2716
    
    6

Originally posted by Pat Farrell:


Don't set an expiration time.

Reset it every time a user revisits.

If you forget when they have not returned within months, its no big deal


Its not true, Google has set cookies in my browser, some of which will expire by 2010.


SCJP, SCWCD.
|Asking Good Questions|
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Cookie Question