Can I change the value of a cookie and leave the expiration date in PHP?

Let's say I have a PHP script that creates a cookie that expires in 10 days. Is there a way to use PHP to update the value and keep the same expiration date?

For example, let's say my cookie is created today with the value "foo" and expires 3/13/10. Two days later I want to change the value to "bar". Can I wait for the cookie to expire in the thirteenth year, or am I forced to either immediately release the cookie or extend it by 10 days?

+5
source share
3 answers

It's impossible.

HTTP ( HTTP, Firebug), , , .

( , ) - cookie ...

+2

, , cookie, , , . , cookie, , , cookie, , , .

+1

impossible.

It is also very bad practice to rely on the expiration date of a cookie. If you have certain restrictions on its use, save them in the database and use cookies only to identify a specific user.

0
source

All Articles