title: nodejs read session from database
body: <p>Im writing an application using nodejs, nowjs, codeigniter and mysql. Im using database to store the session. Is there a good way to check and retrieve the session cookie in nodejs? So if that for example, i need to check if a user owns a specific row in the database that is about to get deleted, using nowjs. e.g:</p>
  
  <p>server:</p>
  
  <pre><code>//some code here to get session cookie and retrieve stored data from database
  
  var session = { user_id: //userid from database }
  
  everyone.now.deleteGuestbook = function(recordId) {
      var owner_id = client.query(
          'SELECT owner_id FROM guestbook WHERE id = ?',
          [recordId]
      );
      if (session.user_id === owner_id) {
          client.query(
          'DELETE FROM guestbook WHERE id = ?',
          [recordId], function() {
                   everyone.now.deleteRecord;
              }
          );
      }
  }
  </code></pre>
  
  <p>client:</p>
  
  <pre><code>//Delete guestbook record
  $('#guestbook_records li').live('click', function(e) {
      if ($(e.target).is('a.delete')) {
          var id = $(this).find('a.delete').attr('href');
          dialogBox('warning', 'Are you sure you want to delete the record?',
              function() {
                  now.deleteGuestbook(id);
              });
      }
      else {
          return;
      }
      return false;
  });
  
  now.deleteMessage = function(id) {
      $('li[class="' + id + '"]').slideUp(400, function() {
          $(this).remove();
      });
  };
  </code></pre>