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