Skip to content
This repository has been archived by the owner on Feb 3, 2020. It is now read-only.

Don't throw on invalid cookies #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

bkw
Copy link

@bkw bkw commented Mar 18, 2011

Since cookies are user input, we shouldn't throw an exception if the cookie does not pass our tests.
Imho ignoring it is sufficient.

Maybe we could emit an event for debugging purposes, but certainly not an error.

@lloyd
Copy link
Contributor

lloyd commented Jun 21, 2011

+1. As it stands now, client code must clumsily work around it at a higher level, something like:

server.use(express.cookieParser());

var cookieSessionMiddleware = sessions({
    secret: COOKIE_SECRET,
    session_key: COOKIE_KEY,
    path: '/'
});

server.use(function(req, resp, next) {
    try {
        cookieSessionMiddleware(req, resp, next);
    } catch(e) {
        console.log("invalid cookie found: ignoring");
        delete req.cookies[COOKIE_KEY];
        cookieSessionMiddleware(req, resp, next);
    }
});

@hiddentao
Copy link

+1

@jasoo24
Copy link

jasoo24 commented May 30, 2012

+1

Is this project still being worked on? Any better alternatives?

@lloyd
Copy link
Contributor

lloyd commented May 31, 2012

We're now using benadida/node-client-sessions - fwiw

--lloyd

On May 31, 2012, at 1:41 AM, Jason Arorareply@reply.github.com wrote:

+1

Is this project still being worked on? Any better alternatives?


Reply to this email directly or view it on GitHub:
#9 (comment)

@lloyd
Copy link
Contributor

lloyd commented May 31, 2012

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

Successfully merging this pull request may close these issues.

4 participants