Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Session lost on node restart #1

Closed
JD-Robbs opened this issue Sep 20, 2016 · 3 comments
Closed

Session lost on node restart #1

JD-Robbs opened this issue Sep 20, 2016 · 3 comments

Comments

@JD-Robbs
Copy link

First of all: great session middleware - it works really well as a drop-in replacement for koa-generic-session. Thanks!

I am using this in conjunction with the redisStore and, whenever node restarts, the session is lost.

The secret option is a fixed string - so I'm not so sure why this is happening.

Just putting it out there in case it's not just me. 😄

@lzztt
Copy link
Owner

lzztt commented Sep 21, 2016

@JD-Robbs Thanks for the feedback!

I am thinking how to reproduce the session lost issue. I tested with
node example/02_redis_store.js
session data persists (in browser and redis store) after I restart node.

@lzztt
Copy link
Owner

lzztt commented Sep 21, 2016

The secret option is a fixed string

what secret option are you referring to?

@JD-Robbs
Copy link
Author

Hi @longztian,

Thanks for pointing me to the example.

After trying it (and it working), I realised that I must've been doing something wrong.

app.use(session({
    secret: "some_static_secret",
    store: redisStore(),
    cookie: {
        path: '/',
        httpOnly: true,
        maxage: null,
        rewrite: true,
        signed: true
    }
}));

// app.use(session(app)); <-- This was the issue.

Thanks for your help!

P.S.: I assumed the session secret option is used to secure the session. But I just realised that app.keys is used in Koa.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants