title: how to create session using mongodb in node.js
body: <p>i am trying to create session with mongodb in node.js
  already i have a connection like this</p>
  
  <pre><code>var Db=require('mongodb').Db;
  
  
  var BSON=require('mongodb').BSONPure;
  
  var Server=require('mongodb').Server;
  
  
   var client=new Db('db',new Server('localhost', 27017), {safe:false});
  </code></pre>
  
  <p>and then i have tried to configure session like this</p>
  
  <pre><code> app.use(express.session({
  
     store: new mongoStore({ db: client }),
      secret: 'topsecret'
  
     }));
  </code></pre>
  
  <p>i ran the server.js file i got this error mongoStore undefined 
  so to resolve this error i have added this</p>
  
  <pre><code>  var mongoStore= require('connect-mongodb');
  </code></pre>
  
  <p>again i ran it i did't get any error but i got below error   when i tried to find or save data into db </p>
  
  <pre><code>    Cannot call method 'findOne' of undefined
  </code></pre>
  
  <p>how to resolve this problem and how to create session with mongodb in node.js</p>