0

I am facing a strange issue while setting and deleting cookies.

I am setting a cookie with the line below:

setcookie( $cookie, base64_encode( $step . $val ), time() + 3600, '/', 'domain.com' );

The cookie is set correctly with the given expiration time.

Trying to delete it with the following line:

setcookie( $cookie, '', time() - 3600, '/', 'domain.com' );

This does not remove the cookie, rather firebug shows this as a session cookie now!!

Can you please let me know what i might be doing wrong.

Thanks

web-nomad
  • 6,003
  • 3
  • 34
  • 49
  • possible duplicate of [Remove a cookie](http://stackoverflow.com/questions/686155/remove-a-cookie) – njzk2 Dec 01 '14 at 16:41
  • I tried that, but doesn't work. – web-nomad Dec 01 '14 at 16:44
  • Don't use relative times for deleting a cookie. Just set time `1`, since you have no idea whether the user's system is actually "in sync" with real time. e.g. their clock could be 2 hours slow, in which case you're setting an expiry time one hour in THEIR future. – Marc B Dec 01 '14 at 16:57
  • actually, i am using `date_default_timezone_set` for setting and deleting the cookies – web-nomad Dec 01 '14 at 17:30

0 Answers0