safari cookie issue

2020-04-30 03:08发布

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条回答
做个烂人
2楼-- · 2020-04-30 03:58

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

查看更多
Viruses.
3楼-- · 2020-04-30 04:00

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 ;)

查看更多
登录 后发表回答