In the end i solved it using localStorage in ios instead of cookie, if someone is to answer the question correctly i'll mark his as the right answer.
Cookie not saving in safari when adding to home screen
-
29-11-2021 - |
Question
Hey i'm using the following code to set a cookie and get it :
$.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.
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:
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?
La solution
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow