-
Notifications
You must be signed in to change notification settings - Fork 27.4k
$cookies doesn't represent current state of document.cookie #7631
Comments
The With that said you could use |
@amaltson Alternatively, you could register an http interceptor to update the |
+1 for fixing this |
Up! Faced the same problem, solved with $browser.cookies(). |
If |
The new API on `$cookies` includes: * `get` * `put` * `getObject` * `putObject` * `getAll` * `remove` The new API no longer polls the browser for changes to the cookies and no longer copy cookie values onto the `$cookies` object. The polling is expensive and caused issues with the `$cookies` properties not synchronizing correctly with the actual browser cookie values. The reason the polling was originally added was to allow communication between different tabs, but there are better ways to do this today (for example `localStorage`). DEPRECATION NOTICE: `$cookieStore` is now deprecated as all the useful logic has been moved to `$cookies`, to which `$cookieStore` now simply delegates calls. BREAKING CHANGE: `$cookies` no longer exposes properties that represent the current browser cookie values. Now you must explicitly the methods described above to access the cookie values. This also means that you can no longer watch the `$cookies` properties for changes to the browser's cookies. This feature is generally only needed if a 3rd party library was programmatically changing the cookies at runtime. If you rely on this then you must either write code that can react to the 3rd party library making the changes to cookies or implement your own polling mechanism. Closes #6411 Closes #7631
The new API on `$cookies` includes: * `get` * `put` * `getObject` * `putObject` * `getAll` * `remove` The new API no longer polls the browser for changes to the cookies and no longer copy cookie values onto the `$cookies` object. The polling is expensive and caused issues with the `$cookies` properties not synchronizing correctly with the actual browser cookie values. The reason the polling was originally added was to allow communication between different tabs, but there are better ways to do this today (for example `localStorage`). DEPRECATION NOTICE: `$cookieStore` is now deprecated as all the useful logic has been moved to `$cookies`, to which `$cookieStore` now simply delegates calls. BREAKING CHANGE: `$cookies` no longer exposes properties that represent the current browser cookie values. Now you must explicitly the methods described above to access the cookie values. This also means that you can no longer watch the `$cookies` properties for changes to the browser's cookies. This feature is generally only needed if a 3rd party library was programmatically changing the cookies at runtime. If you rely on this then you must either write code that can react to the 3rd party library making the changes to cookies or implement your own polling mechanism. Closes angular#6411 Closes angular#7631
The new API on `$cookies` includes: * `get` * `put` * `getObject` * `putObject` * `getAll` * `remove` The new API no longer polls the browser for changes to the cookies and no longer copy cookie values onto the `$cookies` object. The polling is expensive and caused issues with the `$cookies` properties not synchronizing correctly with the actual browser cookie values. The reason the polling was originally added was to allow communication between different tabs, but there are better ways to do this today (for example `localStorage`). DEPRECATION NOTICE: `$cookieStore` is now deprecated as all the useful logic has been moved to `$cookies`, to which `$cookieStore` now simply delegates calls. BREAKING CHANGE: `$cookies` no longer exposes properties that represent the current browser cookie values. Now you must explicitly the methods described above to access the cookie values. This also means that you can no longer watch the `$cookies` properties for changes to the browser's cookies. This feature is generally only needed if a 3rd party library was programmatically changing the cookies at runtime. If you rely on this then you must either write code that can react to the 3rd party library making the changes to cookies or implement your own polling mechanism. Closes angular#6411 Closes angular#7631
It's not the new hotness. Just upgraded from Angular 1.3 -> 1.4 and the function no longer exists. EDIT: Seems this was fixed correctly in Angular 1.4: 38fbe3e so we don't need this $browser.cookies workaround anymore |
In an
$http
login call that we make, the resulting header has aSet-Cookie
. While the cookie does get set in the browser, i.e. I can see it indocument.cookie
, it doesn't make it's way to$cookies
.Below is the response header setting the cookie:

And here is

document.cookie
indicating the cookie exists but$cookies
doesn't see it.The strangest thing is on the next Angular action I take,
$cookies
has the cookie. The example above is already wrapping the$cookies
check in a$timeout
to give the browser time to digest.The workaround right now is to parse
document.cookie
and set$cookies
manually, but this is super hacky.The text was updated successfully, but these errors were encountered: