Safari 浏览器不处理 cookie - PHP [英] Safari browser not handling cookie - PHP

查看:58
本文介绍了Safari 浏览器不处理 cookie - PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我这两天一直被这个问题困扰,我的主login.php"文件中有以下代码在所有浏览器中运行都没有任何问题,但在Safari"中却没有.

I am stuck on this problem for the last two days, I Have the following code in my main "login.php" file Which is running in all browsers without any problem, but not in "Safari".

 if(isset($_SESSION["del_log"]) && !empty($_SESSION["del_log"]) && isset($_SESSION["user_type"]) && !empty($deal_type)){

            $expire=time()+60*60*24*365;
            setcookie("del_log",$_SESSION["del_log"], $expire, '/');
            setcookie("user_type", $_SESSION["user_type"], $expire, '/');

    echo "<script>window.location.href=\"http://www.sample.com/foldername/index.php\"</script>";
        }

我正在.../foldername/index.php"文件中检查这些cookies:

i am checking these cookies in ".../foldername/index.php" file as:

 if (isset($_COOKIE["del_log"]) && !empty($_COOKIE["del_log"])){
     $log=$_COOKIE["del_log"];
     $user_type=$_COOKIE["user_type"];
 }else{
     echo "<script>window.location.href=\"http://www.sample.com/\"</script>";
 }

推荐答案

之前遇到过这个问题.会话的 cookie 路径 ( http://php.net/manual/en/function.session-set-cookie-params.php ) 必须有一个斜杠才能工作.特定于 Safari.

Encounter this issue before. The session's cookie path ( http://php.net/manual/en/function.session-set-cookie-params.php ) must have a trailing slash in order to work. Safari specific.

看我的另一个问题的答案:https://stackoverflow.com/a/15131791/188331

See my another question's answer: https://stackoverflow.com/a/15131791/188331

这篇关于Safari 浏览器不处理 cookie - PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆