They're not the same, no. res.cookie adds a cookie to the response; req.session is a server-side key/value store. Session data lives in server memory by default, although you can configure alternate stores.
> is it okay for me to use an email, a la mode req.session.user =
> user.id, because email is the key I use to store user credentials in
> redis.
You can store anything you want in a session. The only thing the client sees is a cookie identifying the session.
--
Laurie Harper
http://laurie.holoweb.net/
You can store anything you want in the session, and no extra cookies will be created. On the other hand, if you create a cookie (by calling res.cookie()), the session isn't touched; the one has nothing to do with the other.
Cookies are created by calling res.cookie(), and are sent to the client as part of the response, stored by the client, and sent back to the server with each subsequent request. Sessions are stored by the server, and never sent to the client.
I have no idea where database tokens might come into it... you don't need any kind of database to use cookies, or to use sessions. You can remove all references to connect-redis from your project and your use of sessions/cookies wouldn't change one bit.
The connect-redis module is just a session store: it saves session data (anything you put in req.session) to your redis database. It doesn't know anything about cookies. It doesn't send anything to the client. If you stopped using it, the *only* thing that would change is that your session data would be held in memory on the server, rather than saved into your redis db.
Does that answer your question?
L.
> --
> You received this message because you are subscribed to the Google Groups "Express" group.
> To post to this group, send email to expre...@googlegroups.com.
> To unsubscribe from this group, send email to express-js+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/express-js?hl=en.
app.use(express.cookieParser('secret'));app.use(express.session({ secret: 'secret', key: 'sid', cookie: {secure: true, maxAge: 60000 }}));
--
You received this message because you are subscribed to the Google Groups "Express" group.
To unsubscribe from this group and stop receiving emails from it, send an email to express-js+...@googlegroups.com.
To post to this group, send email to expre...@googlegroups.com.
Visit this group at http://groups.google.com/group/express-js.
For more options, visit https://groups.google.com/groups/opt_out.
Secure cookies will be sent via HTTPS only. Have you set up an HTTPS server? Also, which version of Express are you using?
On Fri, Aug 16, 2013 at 10:12 PM, daslicht <ans...@gmail.com> wrote:
Hello,I have created a simple app to try out sessions which works nice.If I set something like this:req.session.currentUserI can access it in other routes like this:currentUser= req.session.currentUserBut as far as I add the secure option to true its no longer working.Here is the config:app.use(express.cookieParser('secret'));app.use(express.session({ secret: 'secret', key: 'sid', cookie: {secure: true, maxAge: 60000 }}));What Am I missing ?--
You received this message because you are subscribed to the Google Groups "Express" group.
To unsubscribe from this group and stop receiving emails from it, send an email to express-js+...@googlegroups.com.
To post to this group, send email to expre...@googlegroups.com.
Visit this group at http://groups.google.com/group/express-js.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to a topic in the Google Groups "Express" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/express-js/de9sf9Ly_rY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to express-js+...@googlegroups.com.
You received this message because you are subscribed to a topic in the Google Groups "Express" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/express-js/de9sf9Ly_rY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to express-js+...@googlegroups.com.
To post to this group, send email to expre...@googlegroups.com.