0

I am setting a cookie in the Angular app using the CookieService from "ngx-cookie-service". Some of the characters involved in the cookie get converted into different characters when retrieved at the server-side. I wish to stop this behavior of character conversion

This is a new problem for me as I have been trying to achieve this very recently and I am very new to Angular.

public ngOnInit(): void{

  this.cookieService.set('SMSESSION', '4vsKaqcVTzGOr9PTG4JV05s52OLYDjMIriTnYDbIHCKYocP0wcXBtmzojEkL2VzCPdMRNg4osirJKfJMSQT7fv29MsIfYBxhQSxU+GKO/');

  }
}

I expected the output to be like this:

4vsKaqcVTzGOr9PTG4JV05s52OLYDjMIriTnYDbIHCKYocP0wcXBtmzojEkL2VzCPdMRNg4osirJKfJMSQT7fv29MsIfYBxhQSxU`+`GKO`/`

But it gets converted like this

4vsKaqcVTzGOr9PTG4JV05s52OLYDjMIriTnYDbIHCKYocP0wcXBtmzojEkL2VzCPdMRNg4osirJKfJMSQT7fv29MsIfYBxhQSxU`%2B`GKO`%2F`
Ajay S
  • 13
  • 3

1 Answers1

0

You cookie is getting URL encoded. It should also be automatically decoded if you try to read it. Please take a look at this similar posting Should cookie values be URL encoded?.

D Jordan
  • 84
  • 4
  • The link provided in the response helped. So there is specific characters that cannot be set in cookie when we use "ngx-cookie-service" of Angular. This service encodes those characters and hence it needs to be decoded from server side. – Ajay S Sep 09 '19 at 10:21