Jump to content

Can a cookie's value be modified without changing it's expiry date?


alex3

Recommended Posts

I have a cookie with three values:

 

$_COOKIE['Site Name']['session'],['token'],['user']

 

If a user wants to be remembered, a unique token is generated and added to the users row in a DB. When a user revisits the site (revisit = after the user's previous session ID has expired) the token and username values are looked up in the DB, if they exist the user is trusted and a session value is created (equal to session_id()) in the cookie. The session value is the first thing to be checked to prevent lots of DB lookups. If the session value is equal to session_id(), the user is trusted, if not then we check the values of 'user' and 'token'.

 

The crux is that whenever the token value is looked up, it is replaced with a new value (to prevent cookies being stolen and used). I want to update the user's cookie to reflect this new token value, but I don't know how to while keeping the cookie expiry date intact. How can I do this?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.