0

I have a web-page that uses cookies. I've set the expiry on the cookies to 365 days and in the developer console I can see that the expiry is correct. But only on mobile the cookies expire within about a week, instead of a year. From what I've read this has to do with mobile browser sessions but I didn't find a viable solution using JQuery or vanilla JS.

If possible I would like to refrain from switching over to client side session storage. This is the way I set my cookies:

var setCookie = function(cname, cvalue, exdays) {
    var d = new Date();
    d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
    var expires = "expires="+d.toUTCString();
    document.cookie = cname + "=" + cvalue + ";" + expires +" ;"/*path=/"/;*/
}

Taken from here: https://www.w3schools.com/js/js_cookies.asp

  • Upon further inspection the problem appears to only occur on ios. – Arel Sharon Aug 02 '20 at 18:44
  • I've Come Across This Thread https://stackoverflow.com/questions/46774629/cookie-persistence-in-ios-safari-chrome Which stated that domain is required when defining ios cookies and without it they would not be presistent. – Arel Sharon Aug 02 '20 at 18:47

0 Answers0