Angular.js: $cookies.get("JSESSIONID") return undefined

Created on 20 Jul 2016  路  5Comments  路  Source: angular/angular.js

$cookie.get("JSESSIONID") always return undefined even if JSESSIONID cookie is set by the browser.
Angular version: 1.4.9. Checked on Chrome 51.0.2704.103 and Firefox 44.0.2

ngCookies low more info broken expected use bug

Most helpful comment

Still happening to me, angular 1.6.2 and angular-cookie 1.6.2.
I'm on a gulp development environment with browser-sync, angular-ui-router.

These are the "steps" (sorry no time now to update the plunker already provided), I payed attention to not cause any page reload from browser-sync.

  • login state/page: In a "SessionService" I put $cookies.put('JSESSIONID', response.data.portofinoSessionId);
  • the cookie is visible in chrome developer tools for domanin "localhost:3000"
  • change state after login
  • home page: again in the previous "SessionService" try $cookies.get('JSESSIONID') but return undefined
  • the cookie is still visible in chrome developer tools for domanin "localhost:3000"

All 5 comments

Please, provide a runnable demo (e.g. using CodePen, Plnkr etc) or the exact steps and code to reproduce this. Without a concrete reproduction, there is no way we can investigate this.

@pienikrz I tried this in plnkr and I am able to get the value from the cookie. Check this plunker:

http://embed.plnkr.co/hl5s8UqFROwNiimfYYId/

Closing since there was no response from the OP and we don't have a reproduction.
Happy to reopen when/if you can provide more info and/or a reproduction.

Still happening to me, angular 1.6.2 and angular-cookie 1.6.2.
I'm on a gulp development environment with browser-sync, angular-ui-router.

These are the "steps" (sorry no time now to update the plunker already provided), I payed attention to not cause any page reload from browser-sync.

  • login state/page: In a "SessionService" I put $cookies.put('JSESSIONID', response.data.portofinoSessionId);
  • the cookie is visible in chrome developer tools for domanin "localhost:3000"
  • change state after login
  • home page: again in the previous "SessionService" try $cookies.get('JSESSIONID') but return undefined
  • the cookie is still visible in chrome developer tools for domanin "localhost:3000"

I'm having the same issue

Was this page helpful?
0 / 5 - 0 ratings