Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cookie Question

 
Ashish Gauswami
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ashish Gauswami:
so the cookie will expire in few hours.


How do you figure?
 
Pat Farrell
Rancher
Posts: 4678
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2854
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic