0
votes

I am using express and cookie-parser on my nodejs rest server. After the cookie was sent, I can see in the network: Set-Cookie:xxxx=xxxxxxxxxxx; Path=/; Expires=Tue, 29 Dec 2015 18:14:06 GMT; HttpOnly But there is nothing in my Browser cookie. Is it because I'm using localhost?

```

const app = express();

app.use(cookieParser());


app.post('/login', (req, res) => {
  let email = req.body.email;
  let pass = req.body.password;
  (new User()).login(email, pass)
  .then(response => {
    if (response) {
      res.cookie('mid', email, { expires: new Date(Date.now() + 900000), httpOnly: true })
      .send('ok');
    } else {
      res.status(503).end();
    }
  });
});

```

1
Are you sure there's nothing, or is it that you're setting the cookie to httpOnly, and therefore the client has no access to it?ndugger

1 Answers

1
votes

I was using React + Relay and I need to add a

Relay.injectNetworkLayer(
  new Relay.DefaultNetworkLayer('/graphql', {
    credentials: 'same-origin',
  })
);

To make it work.