Jump to content
calvin182

Removing Set Cookies

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);

Share this post


Link to post
Share on other sites
thanks, that doesnt exactly remove the cookie but that helped out :)

I know that's just the way php does it, there is no such thing as removecookie('username',''); :)

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

JavaScript and ASP are the same, to remove a cookie set an expiration date in the past.It must be how it's done.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...