Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/93.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 应用程序重新启动后,mobile safari上的Cookie将消失_Javascript_Ios_Cookies_Safari_Mobile Safari - Fatal编程技术网

Javascript 应用程序重新启动后,mobile safari上的Cookie将消失

Javascript 应用程序重新启动后,mobile safari上的Cookie将消失,javascript,ios,cookies,safari,mobile-safari,Javascript,Ios,Cookies,Safari,Mobile Safari,我有一个用户身份验证网页,使用下面的代码使用javascript设置cookie。它在桌面版Safari上运行良好,但在iOS上使用mobile Safari时(我在iOS6和iOS7上进行了测试),cookie只会一直存在,直到mobile Safari应用程序终止。我可以使用Safari的debug菜单中的web inspector查看cookie最初设置为未来5年的过期日期,我的其他网页可以读取cookie,没有问题,但是如果我重新启动手机或退出mobile Safari并重新启动,相同的

我有一个用户身份验证网页,使用下面的代码使用javascript设置cookie。它在桌面版Safari上运行良好,但在iOS上使用mobile Safari时(我在iOS6和iOS7上进行了测试),cookie只会一直存在,直到mobile Safari应用程序终止。我可以使用Safari的debug菜单中的web inspector查看cookie最初设置为未来5年的过期日期,我的其他网页可以读取cookie,没有问题,但是如果我重新启动手机或退出mobile Safari并重新启动,相同的inspector会显示没有cookie,并且我的网页。我似乎对其他网站设置的cookie没有问题。以前有人见过这个吗?这可能是什么原因造成的

<head><title>Authenticate</title>
<script type="text/javascript">
function setCookie(c_name,value,expiredays)
{
    var exdate=new Date();
    exdate.setDate(exdate.getDate()+expiredays);
    document.cookie=c_name+ "=" +escape(value)+
    ((expiredays==null) ? "" : ";expires="+exdate.toGMTString()+ "; path=/;"); 
    document.cookie="expiration"+ "=" +escape(exdate.toGMTString())+
    ((expiredays==null) ? "" : ";expires="+exdate.toGMTString()+ "; path=/;"); 
}
</script>
<script type="text/javascript">
var address=prompt("Please enter the code:","")
if (address!=null && address!="")
{
    setCookie('address',address,(365 * 5));
    window.history.go(-2)
} else {
    document.write("There was a problem setting the cookie.")
}
</script>
</head>
<body>
</body>
验证
函数setCookie(c_名称、值、过期日期)
{
var exdate=新日期();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+“=”+转义(值)+
((expiredays==null)?“”:“expires=“+exdate.togmString()+”“path=/;”;
document.cookie=“expiration”+“=”+转义(exdate.togmString())+
((expiredays==null)?“”:“expires=“+exdate.togmString()+”“path=/;”;
}
var address=prompt(“请输入代码:”,“”)
如果(地址!=null&&address!=“”)
{
setCookie('地址',地址,(365*5));
window.history.go(-2)
}否则{
document.write(“设置cookie时出现问题”)
}