Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

if secret changes, server throws 503 #16

Open
pomidor24 opened this Issue · 1 comment

1 participant

@pomidor24

If I change secret, module is not able to handle this and just simply throws.

It would be great to have ability to pass errorCallback to it:

app.use(sessions({
    secret: 'hohoho', 
    session_key: 'FactityBets',
    path: '/',
    timeout: 1000 * 60 * 60 * 24 * 3 // 3 days,
    onError: callback(err, req, res) {
        // code to remove cookie
    }
}));

or as an alternative removeCookieOnError : true

@pomidor24

For those who want to go to production with this module. You can remove invalid session with the approach below:

app.use(
    function(req, res, next) {
        try {
            var func = sessions({
                secret: 'hohoho', 
                session_key: 'FactityBets',
                path: '/',
                timeout: 1000 * 60 * 60 * 24 * 3 // 3 days
            });
            func(req, res, next);
        } catch(e) {
            console.log(e);
            res.clearCookie('FactityBets');
            res.redirect('/');
        }
    }
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.