safari cookie issue

安稳与你 提交于 2019-12-31 04:26:06

问题


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?


回答1:


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




回答2:


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



来源:https://stackoverflow.com/questions/11586863/safari-cookie-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!