Home  >  Q&A  >  body text

javascript - express about setting and getting cookies

1. The cookie can be set successfully, but why can’t it be obtained? req.cookies has always been {}
The relevant parsing cookie npm package has been referenced

and the setting is successful.

But when I refresh to get req.cookies, it is always {}. This is why. . . ? ? ?

(1). Debugging is local environment debugging

PHP中文网PHP中文网2662 days ago862

reply all(1)I'll reply

  • 黄舟

    黄舟2017-07-05 10:57:52

    Are the client and server cross-domain?
    Cross-domain requests will not automatically bring cookies. You will know by looking at the Request Headers of the network.
    If you want to bring cookies with cross-domain requests, ajax must set withCredentials: true

    reply
    0
  • Cancelreply