Can someone run up this code on a test machine I'm a tad confused as to why cookie can be "unset" but cannot be value changed or expired etc in php it seems like setcookie() isn't working at all.
<script type="text/javascript" src="jquery.js"></script>
<script src="jquery.cookie.js"></script>
<script>
$.cookie('myCookie', '123' ,'/');
console.log("Created myCookie");
</script>
<?php
echo $_COOKIE['myCookie'];
//Comment/uncomment below as required
//setcookie("myCookie", "BLAH", time()-430000);
//$_COOKIE['myCookie'] = "BLAH";
setcookie('myCookie', '', 1, '/');
echo "<br />unset myCookie";
echo "<br />".$_COOKIE['myCookie'];
?>
<script>
console.log($.cookie('myCookie').length);
if ($.cookie('myCookie').length>0)
{
console.log('Cookie exists ');
console.log($.cookie('myCookie'));
}
else
{
console.log('Yaay! No cookie!');
}
</script>
You seem to be able to create a php <> JS cookie mismatch ie: 2 cookies called exactly the same but storing different data.