Jump to content

Deleting cookies


Plain Flailing

Recommended Posts

I've searched through a number of threads on this topic, but none have seemed to help.

 

I'm having trouble deleting a cookie. I can set it fine like this:

 

setrawcookie("username", $username, time()+3600);

 

But I can't delete it like this:

 

setrawcookie("username", "", 1);

 

I've also tried adding a "/" in the domain parameter:

 

setrawcookie("username", $username, time()+3600, "/");

setrawcookie("username", "", 1, "/");

 

If it matters, the cookie is set on the page mysite.com/login/index.php and is (theoretically) deleted on the page mysite.com/logout/index.php - could the directories be causing the problem? If not, where am I going wrong?

Link to comment
https://forums.phpfreaks.com/topic/93403-deleting-cookies/
Share on other sites

The reason I tried it with 1 is because I read this page, which says it's a more timezone-proof method of setting a time in the past.

 

But now I've tried this and it still doesn't work:

 

setrawcookie("username", "", time()-3600*24, "/");

 

Again, with and without the "/".

Link to comment
https://forums.phpfreaks.com/topic/93403-deleting-cookies/#findComment-478489
Share on other sites

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.