I am using angular 1.2.23, and a nodejs server.
I have an authentification based on express-session 1.9.3.
Here are my options given to express
return {
name: 'session',
secret: signatureKey,
cookie: {
httpOnly: true,
secure: getEnvName() === 'production',
maxAge: 30 * 60 * 1000
},
resave: true,
saveUninitialized: true
};
I need to do a nodejs script, that will auth and fetch data for each users.
Operation should be like this
for each users
The first request create the session, and returned a user item. The second request has a middleware, which required to have a valid http cookie.
I am trying to find a way to get and send back the cookie for the second request, I can't find any documentation.
I accept any suggestion.
whould you use the express-session?
I had the same problem and have no idea by the document
only the first request will response cookie
when requested the cookie store in mongodb expires modified
but the cookie in Browser(responsed) never change untill it's expired then will get a new cookie
so different to asp.net,jee ...
i edit the express-session code too solve the question
"version": "1.11.3"
express-session/index.js
find string "shouldSetCookie"
old code
if (!shouldSetCookie(req)) {
return;
}
setcookie(res, name, req.sessionID, secrets[0], cookie.data);
just delete "restun",the every request will get cookie with new expires
new code if (!shouldSetCookie(req)) { } setcookie(res, name, req.sessionID, secrets[0], cookie.data);
in this way you can edit the cookie and setcookie
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.