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
https://forums.phpfreaks.com/topic/46004-deleting-cookies-doesnt-seem-to-work/
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.

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.