W
W
WizardW2019-07-02 21:31:40
JavaScript
WizardW, 2019-07-02 21:31:40

Why doesn't js-cookies see cookies in the browser?

A question. There is a login route, I go there, set up a new session, a new cookie is written to the browser. Then in react in router I try to take this cookie with js-cookies:

function isLogged() {
  const cookie = Cookies.get("connect.sid");
  console.log(cookie);
  if (!cookie) {
    return 0;
  }
  return 1;
}

I put this function in render routes to discard routes for unauthorized users.
My cors on express:
app.use(
  cors({
    credentials: true,
    origin: "http://localhost:3000",
    optionsSuccessStatus: 200
  })
);

The cookies are successfully sent to the browser, but when I call Cookies.get("connect.sid") == undefined, what's wrong?
5d1ba30779651049554546.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DevMan, 2019-07-02
@WizardW

that cookie is httponly .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question