title: node express, how to clear cookie after log out
body: <p>Basically i'm doing redirect from a.example.com to www.example.com and i expect to be able to delete cookies on www.example.com (because cookie is created with .example.com as the cookie domain), but following code doesn't work.</p>
  
  <p>I know that this question seems like duplicate question, i tried everything from similar question but it doesn't work. See after the code <strong>what i already tried</strong>.</p>
  
  <p>Using express 3.0.3 and node 0.10.32.</p>
  
  <p><strong>express session middleware</strong></p>
  
  <pre><code>...
  var cookiedata = { 
      domain              : '.example.com',
      originalMaxAge      : null,
      httpOnly            : false
  };
  
  app.use(express.session({
          store  : ..., 
          secret : ..., 
          key    : 'express.sid', 
          cookie : cookiedata 
  }));
  ...
  </code></pre>
  
  <p><strong>logout function</strong></p>
  
  <pre><code>function logout(req, res){
      ...
  
      req.session.destroy(function(){
          req.session = null;
  
          res.clearCookie('express.sid', { path: '/' });
          res.redirect('https://www.example.com');
  
      });
  }
  </code></pre>
  
  <p><strong>What i already tried from similar question</strong><br></p>
  
  <ol>
  <li><a href="https://github.com/strongloop/express/issues/691">https://github.com/strongloop/express/issues/691</a><br></li>
  </ol>
  
  <p>So i put <code>path : '/'</code> in express session middleware such as:</p>
  
  <pre><code>app.use(express.session({ ..., path : '/' });
  </code></pre>
  
  <p>No success.</p>
  
  <ol start="2">
  <li><a href="https://groups.google.com/forum/#!topic/express-js/PmgGMNOzhgM">https://groups.google.com/forum/#!topic/express-js/PmgGMNOzhgM</a><br>
  Instead res.clearCookie i used: 
  res.cookie('express.sid', '', {expires: new Date(1), path: '/' });</li>
  </ol>
  
  <p>No success.</p>