Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

angularjs $cookieStore SyntaxError: JSON.parse: unexpected character

Have you got any ideas why I get an error

SyntaxError: JSON.parse: unexpected character

on this code

console.log($cookieStore.get('XSRF-TOKEN'));

the cookie value is

kscJcqrDYSMdZtBleuq8yUrB

?

UPDATE NODE CODE

var currentSession = req.session.passport;
var user = currentSession.user;
res.cookie('USER',JSON.stringify(user) , { maxAge: 900000, httpOnly: false});
like image 549
Whisher Avatar asked Dec 25 '22 11:12

Whisher


1 Answers

$cookieStore is serialized session storage. It gives you error because value of cookie are not serialized.

You need $cookies for your value.

like image 191
Sergey Moiseev Avatar answered Dec 28 '22 06:12

Sergey Moiseev