When logging in to my Yii2 + angularjs page, I create cookie with user data:
$jwt = JWT::encode(array(1,2,3), 'myKey123')
setcookie('myData', $jwt, time() + 3600);
I want to access it in my nodejs + express app - before processing request I have to check, if user didn't change 'myData' cookie. This is how I do it now:
app.use(cookieParser());
app.get('/*', function (req, res, next) {
if(req.cookies.myData) {
jwt.verify(req.cookies.myData, 'myKey123', function(err, decoded) {
if(err)
res.sendStatus(403);
else
return next();
});
} else {
res.sendStatus(403);
}
});
If after I logging in I call expressjs route directly in browser, app sees cookie.
Problem: If route is called by making $http.get() request, expressjs app doesn't see any cookies.
Yii2 and expressjs runs on the same IP, but on different ports, but I've read, that different ports shouldn't be the reason, should it? I've played around with setting different cookie parameters, but nothing seems to help. I'd appreciate any help or hints I could get, thank you!