use*_*607 5 javascript cookies safari mobile-safari ios
我有一个用户身份验证网页,它使用下面的代码使用 javascript 设置 cookie。它在桌面版 Safari 上运行良好,但在 iOS 上使用移动 Safari 时(我在 iOS6 和 iOS7 上进行了测试),cookie 只会持续存在,直到移动 Safari 应用程序终止。我可以使用 Safari 调试菜单中的 Web 检查器来查看 cookie 最初已设置为未来 5 年的到期日期,并且我的其他网页可以读取 cookie 没有问题,但如果我重新启动手机或退出手机Safari 并重新启动相同的检查器显示不存在 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>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
718 次 |
| 最近记录: |