• 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 Question

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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



How do you figure?
 
Rancher
Posts: 4803
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 2856
10
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic