I have a website where I store an authentication token in a cookie with 5-year expiration. Despite that, both desktop and mobile Safari tends to drop this cookie from time to time (sometime it lasts for 2 months, sometime it gets removed in a week). This is very unpredictable to my users.
I also tried storing the same token in Local Storage instead of a Cookie, the result is exactly the same.
Both the cookie and the local storage item are set by JavaScript / AngularJS on the client side:
window.localStorage.setItem('token', 'secret-token');
angular.module('app', ['ngCookies'])
.controller('Ctrl', ['$cookies', function($cookies) {
var expireDate = new Date();
expireDate.setDate(expireDate.getDate() + 5*365);
$cookies.put('token', 'secret-token', { 'expires': expireDate });
}]);
I haven't found any documentation describing this especially random behaviour.