Jon
Jon

Reputation: 137

PHP cookie returning "deleted" as value

This is a really odd issue I'm having, and I'm having a hard time figuring out what's going on. Once in awhile, my cookie returns the value "deleted" instead of its proper value. Do any web browsers turn the cookie value to "deleted" if it has expired?

I've done a ton of Google searches and SO searches, and can't find anything like this.

Has anyone seen this before?

Upvotes: 2

Views: 5644

Answers (1)

Damon Swayn
Damon Swayn

Reputation: 1344

Check to ensure that when you call setcookie() you are setting a reasonable expiry time that will ensure that your cookie will not expire while being used.

From the php documentation (trimmed for important parts):

The time the cookie expires. This is a Unix timestamp so is in number of seconds since the epoch. In other words, you'll most likely set this with the time() function plus the number of seconds before you want it to expire.

If set to 0, or omitted, the cookie will expire at the end of the session (when the browser closes).

EDIT

further down the setcookie() documentation I found this

Cookies must be deleted with the same parameters as they were set with. If the value argument is an empty string, or FALSE, and all other arguments match a previous call to setcookie, then the cookie with the specified name will be deleted from the remote client. This is internally achieved by setting value to 'deleted' and expiration time to one year in past.

i.e. it seems that your cookie is somewhere being updated to either an empty string or being set to false.

Upvotes: 3

Related Questions