Jump to content

Deleting Cookies - Doesn't seem to work ???


magnetica

Recommended Posts

I have tried many examples of how to delete cookies with javascript but none seem to work. I'm not great at javascript but heres what I have:-

 

function delete_cookie ( cookie_to_delete )
{
  var cookie_date = new Date ( );  // current date & time
  cookie_date.setTime ( cookie_date.getTime() - 1 );
  document.cookie = cookie_to_delete += "=; expires=" + cookie_date.toGMTString();
}

 

I then call it on the page load like so:

 

<body onload="deleteCookie">

 

Can anyone explain why its not working? Or please provide me with an example that does, Thanks a lot

Link to comment
Share on other sites

Well The following things are to be looked at:-

 

1) the function name is delete_cookie but the call to the function is deleteCookie.

2) also the function requires a parameter cookie_to_delete and no parameter is being passed to the function.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • 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.