-
Notifications
You must be signed in to change notification settings - Fork 27.5k
$cookieStore not working in IE or Safari #1191
Comments
This is also raised as issue 1090 (#1090). Can this get labelled as a bug? |
I am too experiencing this issue on Safari or Internet Explorer 9 with angularJS and angularjs-cookie 1.0.1. Setting and retrieving value works fully in Chromium 18.0.1025.151 and Firefox 14.0.1. Not sure whether it's setting or retrieving value that fails. Is it possible to list cookies set in Safari? My specific usecase is:
|
Any further information on this? I think the issue is probably with the cookieStore.put method. |
+1 major issue if you rely on angular from my point of view. |
+1, still an issue! |
+1 major issue! |
I also couldn't get the $cookieStore to work for me. went back to jQuery plugins for now! :( |
Found it. The problem occurs in this line in browser.cookie (in angular.js) because cookiePath is undefined:
The resulting string ends in "path=undefined". This string is passed to the native document.cookie setter function. It seems that Safari and Chrome have different behavior here and Chrome is more forgiving. Chrome treats the string as if it ended as "path=" and assigns the cookie accordingly, while Safari silently ignores the cookie assignment and leaves the cookie unchanged. The fix/workaround can be applied a few lines earlier to where cookiePath is assigned:
Add the line below so that cookiePath will become "" instead of "undefined"
NOTE: the reason cookiePath can be undefined is because the code derives it from the tag in the document. The undefined result occurs when no tag is specified. The thing I don't understand is whether it is desirable to always set path from base. It seems perhaps a non-obvious consequence of setting . |
The workaround works and is needed, why don't you make a pull request? |
+1 |
2 similar comments
+1 |
+1 |
+1, currently having to use the jquery.cookie plugin because of this. |
+1, and fyi this is broken in Safari in iOS also |
+1 Thanks Fredrik, I just verified this fix worked for me. Please merge this, it's a pretty severe bug! |
Safari and IE don't like being told to store cookies with path set to undefined. This change ensures that if base[href] (from which cookie path is derived) is undefined then the cookie path defaults to ''. The test verifies that the cookie is set instead of checking that cookie has correct path, this is due to that cookie meta information is not avabile once the cookie is set. Closes angular#1190, angular#1191
Safari and IE don't like being told to store cookies with path set to undefined. This change ensures that if base[href] (from which cookie path is derived) is undefined then the cookie path defaults to ''. The test verifies that the cookie is set instead of checking that cookie has correct path, this is due to that cookie meta information is not avabile once the cookie is set. Closes #1190, #1191
Safari and IE don't like being told to store cookies with path set to undefined. This change ensures that if base[href] (from which cookie path is derived) is undefined then the cookie path defaults to ''. The test verifies that the cookie is set instead of checking that cookie has correct path, this is due to that cookie meta information is not avabile once the cookie is set. Closes #1190, #1191
fixed by 7cb8f8f |
I just finished creating my first angular app, and submitting this bug out of memory. Using AngularJS 1.0.1. My app checks for presence of params stored in session cookies, via $cookieStore. If the params were not found, then user was redirected using $location service to the login page. This worked great in Chrome and firefox, but is broken in IE 8 and I believe Safari (latest). I had to abandon the $cookieStore and use jStorage instead.
The text was updated successfully, but these errors were encountered: