How can I make the connect.sid cookie itself only a session cookie instead of a persistent one?
I unsuccessfully tried
app.use(express.session({cookie: { path: '/', httpOnly: true}, secret:'eeuqram'}));
But the cookie still had the expiration timestamp.
var cookieSession = require('cookie-session') var express = require('express') var app = express() app. use(cookieSession({ name: 'session', keys: ['key1', 'key2'] })) // Update a value in the cookie so that the set-cookie will be sent. // Only changes every minute so that it's not sent with every request.
express-session stores only a session identifier on the client within a cookie and stores the session data on the server, typically in a database.
The cookie allows the server to identify the user and retrieve the user session from the session database, so that the user session is maintained. A cookie-based session ends when the user logs off or closes the browser. Cookie-based session management is secure and has performance benefits over alternatives.
Cookies and sessions make the HTTP protocol stateful protocol. Session cookies: Session cookies are the temporary cookies that mainly generated on the server-side. The main use of these cookies to track all the request information that has been made by the client overall particular session.
app.use(express.session({cookie: { path: '/', httpOnly: true, maxAge: null}, secret:'eeuqram'}));
The above worked. So by setting maxAge to be null, I did manage expressjs to use session cookies. Phew.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With