angularcookiesangular-universalngx-cookie-service

NGX Cookie service returns nothing


I'm using NGX Cookie Service in my AuthGuard.ts to check if a user is logged in using a cookie. The problem is when I try to get the raw value of the cookie user the function get it always returns me a blank string.

However I can still create a cookie and that works fine.

I did put the cookie as a provider in my App Module and also in my child modules.

I'm Using angular 8 with Angular Universal.

Any ideas how can I fix this weird bug?

Thanks in advance


Solution

  • Cookies set with httpOnly cannot be read from the browser (see documentation)

    Using httpOnly is more secure, so I'd advise that you leave it enabled

    When using angular universal, you should only try to access these cookies when the code is executed server side.