1
votes

I am pulling my hair out on this. It works on chrome and Firefox but not in safari. What am I doing wrong?

I am setting up a temp cookie and then check if it is set or not. When I clear all the cookies from safari, and then I run this file, it thinks that cookie is still there.

here is the code

setcookie("testcookie", 'cookiesetting temporary');
if(isset($_COOKIE['testcookie'])){
    echo "cookie set":
}else{
    echo "no cookie set";
}

In safari only, after disabling the cookies and removing all the cookies , when I run the code above, it still echoes cookie set.

Just to make sure, I also looked in the dev tools in safari under resources and I see no cookie there.

What am I missing here?

2
If you want to know if cookies are send by your browser, check the request headers. Unless you have not verified that your Safari does not send the cookie any longer, I would trust PHP that says the cookie is there. That simple it is. When you debug, debug at the right place. Find out about facts, not just looking around (looking around is okay for let's say the first 5 minutes, but not longer. After that, go straight for facts, even if you need to learn the whole HTTP standard first. It's worth anyway.) - hakre

2 Answers

1
votes

I had the same problem with Safari (couldn't unset a cookie). You should solve setting the path

setcookie('testcookie', 'cookiesetting temporary', time()+3600, '/path/'); // set 
setcookie('testcookie', '', time()-3600, '/path/'); // delete

Hope this works ;)

0
votes

Simply clearing them client side isn't the proper way to test this .. Have you tried actually "unsetting" the cookie Server Side?