Merge pull request #22 from mhalttu/master

Fix: You can't set a cookie after you have removed another cookie
dev
grevory 11 years ago
commit 4b74562d85

@ -190,10 +190,12 @@ angularLocalStorage.service('localStorageService', [
try { try {
var expiry = '', expiryDate = new Date(); var expiry = '', expiryDate = new Date();
if (value === null) { 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 = ''; value = '';
} } else if (cookie.expiry !== 0) {
if (cookie.expiry !== 0) {
expiryDate.setTime(expiryDate.getTime() + (cookie.expiry*24*60*60*1000)); expiryDate.setTime(expiryDate.getTime() + (cookie.expiry*24*60*60*1000));
expiry = "; expires="+expiryDate.toGMTString(); expiry = "; expires="+expiryDate.toGMTString();
} }