title: Session in nodejs
body: <p>sorry for newby question, but can you explain me how to use sessions in nodeJS. I read a lot of articles in internet but I didn't success to implement something for my purpose (data is saving the session, but every new request session is empty), can you give example from the beginning how to initialize and how to use.</p>
  
  <p>Purpose: when user do login in the system, I need to open session for him and every request that he will send in the future I need to check is his session exist?</p>
  
  <p>I'm using express 4.x. I do it like:</p>
  
  <pre><code>// init session
  app.use(cookieParser());
  app.use(session({
    secret : "yepiMobileSession",
    resave : true,
    key : "session",
    store: mongooseSession(daoService.mongoose), 
    saveUninitialized : true
  }));
  
  
  // save user to the session
  request.session[CONST.SESSION_USER] = user;
  
  // Check login
  function checkLogin(id){
          var user = request.session[CONST.SESSION_USER];
          if (user &amp;&amp; request.params.clientData &amp;&amp; user._id == id){
              return true;
          } else {
              return false;
          }
      }
  </code></pre>