[英]Cookie not saving in safari when adding to home screen
Hey i'm using the following code to set a cookie and get it : 嘿,我正在使用以下代码来设置Cookie并获取它:
$.cookie('SimMobileUsername', $('#user_id').val());
if($.cookie('SimMobileUsername') != "null" && $.cookie('SimMobileUsername') != null); {
$('#user_id').val($.cookie('SimMobileUsername'));
}
Which works fine but when i add the webpage to the home screen it dosen't save the cookie. 效果很好,但是当我将网页添加到主屏幕时,它没有保存cookie。
Important: 重要:
I have read that safari caches home screen pages, so i tried the following code to refresh the page on 1 time on start but that didn't help either: 我已经阅读过Safari浏览器缓存主屏幕页面的信息,因此我尝试使用以下代码在启动1次后刷新页面,但这无济于事:
var url = window.location.href;
if (url.indexOf('rnd=') == -1) {
url = (url.indexOf("?") == -1 ? url + "?rnd=" : url + "&rnd=") + Math.random();
window.location.href = url;
}
Any insights on the subject? 关于这个问题有什么见解吗?
最后,我在ios中使用localStorage而不是cookie解决了该问题,如果有人正确回答了该问题,我会将其标记为正确答案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.