Jump to content

Removing Set Cookies


calvin182

Recommended Posts

I've figured out how to set a cookie using php but I want to set up a link to remove that cookie. Some help please?

If you send a cookie that consists of a name without a value, it will have the same effect as deleting the existing cookie of the same name.Examplecreate a cookie called username
setcookie('username','scott');

to deletet the cookie called username

setcookie('username','');

As an added precaution, you can also set an expiration date that's in the past

setcookie('username','',time()-60);

Link to comment
Share on other sites

you would think php would have a way to actually delete cookies considering it has a way to set them instead of just nullifying it. I see IPB has a link on it saying 'delete coookies set by this board' which leads me to consider the possibility that maybe javascript can do this? any thoughts? it's not completely neccessary anymore, I guess nullifying it will do fine, but I am a bit currious.

Link to comment
Share on other sites

setting an expiration date in the past (like the method you posted above) didn't work for me, the cookie was still present. I'll try again tho because I changed some thing before hand and I might have messed it up.EDIT: I tried again and it worked! I forgot to include some variables the first time hehe but that method has completely removed the cookie, thanks alot!

Edited by calvin182
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...