Angular cookies appearing with encoded characters Angular cookies appearing with encoded characters angularjs angularjs

Angular cookies appearing with encoded characters


Here is the official doc for $cookieStore:

Provides a key-value (string-object) storage, that is backed by session cookies. Objects put or retrieved from this storage are automatically serialized or deserialized by angular's toJson/fromJson.

Then the store save the URL encoded version of the value. Take a look at this article, there is a section explaining the cookie encoding.


$cookieStore.(get/put) automatically run to/from Json on the value you send over, which appends the encoded characters.

If you were to just use $cookies then you can get away with setting your parameters as such

$cookies['savedDevice'] = $scope.deviceChoice.name;

or

$cookies.savedDevice = $scope.deviceChoice.name;

Either way, the values are saved just like you want em to be.

Usage of $cookieStore is popular, however comes with it's own baggage if you want to use the values on the server.