From 69de00f3506601dd0f1f590b2f05b6ccea81502f Mon Sep 17 00:00:00 2001 From: Markus Halttunen Date: Thu, 8 Aug 2013 14:45:41 +0300 Subject: [PATCH] Fixed a problem where you couldn't set a cookie after you had removed another one. The problem is that we shouldn't modify the expiry field of the shared cookie object. Now we simply set the expiry date of the removed cookie without touching the cookie object itself. --- localStorageModule.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/localStorageModule.js b/localStorageModule.js index e74b0d0..61ac509 100644 --- a/localStorageModule.js +++ b/localStorageModule.js @@ -184,10 +184,12 @@ angularLocalStorage.service('localStorageService', [ try { var expiry = '', expiryDate = new Date(); if (value === null) { - cookie.expiry = -1; + // Mark that the cookie has expired one day ago + expiryDate.setTime(expiryDate.getTime() + (-1 * 24*60*60*1000)); + expiry = "; expires="+expiryDate.toGMTString(); + value = ''; - } - if (cookie.expiry !== 0) { + } else if (cookie.expiry !== 0) { expiryDate.setTime(expiryDate.getTime() + (cookie.expiry*24*60*60*1000)); expiry = "; expires="+expiryDate.toGMTString(); }