Where does secure-session store session data?

222 views Asked by At

I've started using @fastify/secure-session in my app, and I can't find anything on the docs to say where it's storing data. I was planning to use redis, but it's not using that (yet). It can't be in memory as restarting the app doesn't lose the session data. Can anyone tell me where it is?

import fastifyCookie from '@fastify/cookie'
import fp from 'fastify-plugin'
import secureSession from '@fastify/secure-session'
import path from 'path'
import fs from 'fs'

export const sessionPlugin = fp(async (app, options, next) => {
    app.register(secureSession, {
        // the name of the attribute decorated on the request-object, defaults to 'session'
        sessionName: 'session',
        // the name of the session cookie, defaults to value of sessionName
        cookieName: 'my-session',
        // adapt this to point to the directory where secret-key is located
        key: fs.readFileSync(path.join(config.root, 'secret-key')),
        cookie: {
            domain: 'mydomain.com',
            path: '/'
            // options for setCookie, see https://github.com/fastify/fastify-cookie
        }
    })

    app.addHook('onRequest', (req, res) => {
        console.log(req.cookies) // shows my-session cookie
    })
})
0

There are 0 answers