expressjs / cookie-session

Simple cookie-based session middleware

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

how to force not to save cookies?

dinukasal opened this issue · comments

How can I decidee whether to save cookies or not based on a req.body property for example remember_me checkbox?

Since this module doesn't actually set the cookie unless you add something to the session, the easiest solution is don't add anything to the session if you don't want the session to be created.

Alternatively if you added something to the session and later in the code decided you don't want the session, you can destroy it with req.session = null