Search code examples
node.jssessioncookiesexpresssession-storage

What's the advantage of using express' session over the HTML5 global sessionStorage object?


My understanding is that, in apps using express on top of node, the session object can be accessed through req.session, which can have any number of key/value pairs set on it.

What's the advantage of using this method over storing key/value pairs on the global sessionStorage object in the DOM?


Solution

  • There are several advantages:

    • express.session stays on your server, so you can store things there that won't be accessible to the client
    • express sessions don't have storage limits
    • Storing things in the DOM mean you'll have to transmit everything over the wire, incurring extra bandwidth costs.