The question basically explains it all, I'm trying to delete the cookie in PHP and also sending JS to delete the cookie as well, not working ONLY in Chrome...
<?php
unset( $_COOKIE['name'] );
setcookie('name', '', time() - 3600 ); // empty value and old timestamp
?>
<script type="text/javascript">
function deleteCookie( name ) {
document.cookie = name + '=;expires=Thu, 01 Jan 1970 00:00:01 GMT;';
}
deleteCookie('name');
</script>
<a href="cookie.php">cookie</a>
All help is appreciated, thanks!
EDIT: Firebug in Firefox shows no errors, PHP error log shows nothing... the only other thing I can see is that chrome seems to be conserving 1 particular value. name=ABCDE ... if I change it to name=ABC then delete name=ABC it will show name=ABCDE, if I delete name=ABCDE it will still show name=ABCDE
Somewhere during development some wires got crossed, I went into chrome settings and deleted the cookies and all data from my domain:
https://superuser.com/questions/548096/how-can-i-clear-cookies-for-a-single-site
and now it works great! I saw other people on forums with this same issue, I encourage you to do the same...
I don't even send the JS code anymore PHP takes care of it!
Why don't you try changing the value of the cookie to be something different, when deleted?
That will avoid the problem of setting the expiration date to a date in the past and hoping the browser will delete it.
So, for example, ABCDE=deleted; expires=Thu, 01 Jan 1970 00:00:01 GMT;
instead of ABCDE=;expires=Thu, 01 Jan 1970 00:00:01 GMT;
Now you can check if it was supposed to be deleted, but still exists in Chrome with:
if(document.cookie.indexOf('ABCDE=deleted') !== -1)
{
// cookie still exists, but was supposed to be deleted
}