title: Cookie not being set in nodejs
body: <p>I have the following code</p>
  <pre><code>   passport.authenticate(&quot;local&quot;, (err, token, user) =&gt; {
          if (err) {
              console.dir(err);
              res.json({
                  status: &quot;error&quot;,
                  error: &quot;Invalid user.&quot;,
              });
              res.end();
          }
          if (!user) {
              res.json({
                  status: &quot;error&quot;,
                  error: &quot;Invalid user.&quot;,
              });
              res.end();
          } else {
              req.logIn(user, (err) =&gt; {
                  if (err) {
                      console.dir(err);
                      res.json({
                          status: &quot;error&quot;,
                          error: &quot;Invalid user.&quot;,
                      });
                      res.end();
                  }
  
                  res.clearCookie(&quot;auth&quot;);
                  res.cookie(&quot;auth&quot;, token);
  
                  console.dir('test12');
                  console.dir(req.cookies);
  
                  return res.json({
                      status: &quot;ok&quot;,
                      token: token,
                      result: user,
                      mentorId: user &amp;&amp; user.mentor ? user.mentor.id : null,
                  });
              });
          }
      })(req, res, next);
  </code></pre>
  <p>for some reason, the cookie &quot;auth&quot; is not being set on the server. Can someone help?
  I'm trying to log in the user and set a token cookie.</p>