How to get values from cookies using angular?

338 views Asked by At

I have a system on the Internet that enables me to add custom applications to it through a window within this system. When you enter this window, the user session hash will be sent to the URL of the my custom application by GET method. By default, the web server sends the following cookies when an external application link opens:

  • User session hash as hash=c75b8k45y2hf5j9w6d394v98.
  • Locale as locale=en.

enter image description here

My question, How can I get session hash value to use it in my custom page in angular?

I tried this code but it didn't work:

import { CookieService } from 'ngx-cookie-service';
constructor(private cookieService: CookieService){}
ngOnInit(): void
 {
    console.log("Hash is : ",this.cookieService.get("session_key"));
    console.log("session_key is : ", this.cookieService.get("session_key"));
    console.log("local is : ", this.cookieService.get("locale"));
 }

But the result in console is empty. enter image description here

0

There are 0 answers