I'm trying to just remeber a user returning to the site and count views, only after 5 minutes. I did this, works when using Firebase Serve
, but the cookies are not being stored after deploy.
Somewhere up in the app.
app.use(cookieSession({ name: 'session', keys: ['utl__key_s1', 'utl__key_s2'] }));
Trying to check if session exists and isn't more than 5 min old.
function sessionExists(req) {
const t = req.session.viewTime;
if (t == null) {
req.session.viewTime = + new Date();
return false;
}
const fiveMinutes = ((1000) * 60) * 5;
if (((+new Date()) - t) > fiveMinutes) {
req.session = null;
return false;
}
return true;
}
Then I find out the issue is that we have to use __session. That I don't really understand. Can I get an example with context to the above code examples?