tags:

views:

13

answers:

1

Hello

In an application I'm working on, a cookie is created for a new user when they visit the site. The cookie stores an ID no and is set to expire in a year.

It is possible to reset the age of this cookie upon the user revisiting the site at all? I would rather not delete and recreate the cookie. Or can I create an 'immortal' cookie?

Mr Morgan.

A: 

Just set the cookie again with the same name - no need to "delete" it first.

"Immortal" cookies can be created by using an expiration time long in the future (say 30 years). They're likely just as immortal as cookies whose expiration date you keep resetting, though.

Matti Virkkunen
With the same name? I thought it would have to be updated via setMaxAge?
Mr Morgan
@Mr Morgan: You didn't exactly say anything about your server side platform of choice. I don't know Java(?) personally, but my answer applies to anything though.
Matti Virkkunen
@Matti Virkkunen: It is Java I'm using via Tomcat as an servlet container. Thanks.
Mr Morgan