Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is because you use MemoryStore (default) for sessions. Look at this code from memory.js (part of Connect framework):</p> <pre><code>var MemoryStore = module.exports = function MemoryStore() { this.sessions = {}; }; </code></pre> <p>and this snippet from session.js (Express)</p> <pre><code>function session(options){ /* some code */ , store = options.store || new MemoryStore /* some code */ } </code></pre> <p>Now you should understand that every server restart resets the MemoryStore. In order to keep the data you have to use some other session store. You can even write your own (shouldn't be too difficult), although Redis (see <a href="https://github.com/visionmedia/connect-redis" rel="noreferrer">this library</a>) might be a good choice (and it is well supported by Express).</p> <p><strong>// EDIT</strong></p> <p>According to <a href="http://www.senchalabs.org/connect/middleware-session.html" rel="noreferrer">the Connect documentation</a> it is enough for you if you implement <code>get</code>, <code>set</code> and <code>destroy</code> methods. The following code should work:</p> <pre><code>customStore = { get : function(sid, callback) { // custom code, for example calling MongoDb }, set : function(sid, session, callback) { // custom code }, destroy : function(sid, callback) { // custom code } } app.use(express.session({ store: customStore })); </code></pre> <p>You just need to implement calling MongoDb (or any other Db although I still recommend using nonpermament one like Redis) for storing session data. Also read the source code of other implementations to grab the idea.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload