You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix is putting the cookie's expiration in the hash:
if(this===sess&&key==='cookie'){// we want `touch` to affect the hash of the sessionreturnsess.cookie.expires?.getTime()}}
Steps to Reproduce
test('should set session cookie if saveUninitialized is false and maxAge is on',async(t)=>{t.plan(2)constoptions={cookie: {maxAge: 42},secret: 'cNaoPYAwF60HZJzkcNaoPYAwF60HZJzk',saveUninitialized: false}constplugin=fastifyPlugin(async(fastify,opts)=>{fastify.addHook('onRequest',(request,reply,done)=>{request.sessionStore.set(DEFAULT_SESSION_ID,{// In this scenario, maxAge would have set expires in a previous requestcookie: {expires: newDate(Date.now()+1000)}},done)})})constfastify=awaitbuildFastify((request,reply)=>reply.send(200),options,plugin)t.teardown(()=>fastify.close())constresponse=awaitfastify.inject({url: '/',headers: {cookie: DEFAULT_COOKIE,'x-forwarded-proto': 'https'}})t.equal(response.statusCode,200)t.ok(response.headers['set-cookie'])})
Expected Behavior
The session should re-save
The text was updated successfully, but these errors were encountered:
Prerequisites
Fastify version
4
Plugin version
9
Node.js version
16
Operating system
Linux
Operating system version (i.e. 20.04, 11.3, 10)
Description
Currently, if maxAge is on and saveUninitialized is false, we don't re-save the session.
See this for original discussion:
#144 (comment)
Fix is putting the cookie's expiration in the hash:
Steps to Reproduce
Expected Behavior
The session should re-save
The text was updated successfully, but these errors were encountered: