简体   繁体   中英

Set-Cookie in response header is not saved into browser cookie storage

the response header is

Access-Control-Allow-Credentials:true
Access-Control-Allow-Headers:Origin, X-Requested-With, x-request, Content-Type, Accept
Access-Control-Allow-Origin:*
Cache-Control:private
Connection:close
Content-Length:100
Content-Type:application/json; charset=utf-8
Date:Tue, 14 Feb 2017 02:45:56 GMT
Server:nginx/1.2.8
Set-Cookie:USER=6ae633831f39447688892e6b2b156cec; Max-Age=604800; Path=/
Set-Cookie:USERINFO=298967; Max-Age=604800; Path=/
X-Powered-By:node.js
X-Ua-Compatible:chrome=1

the cookie format's right (used cookie package to serialize ). the server is developed by node.js.

not only chrome, Firefox doesn't work too. the document.cookie is empty and also i can't see cookie in application section of chrome developer tool.

Any wrong in response header ?? Please help .

This problem occur due to multiple responses from server to client.

For example if you are sending a response to the server using response.send() and same time using you are using response.setHeader()

This problem can be solve by creating cookie in client side using javascript. And reading its value from node.js

答案是因为我使用了必须通过{credentials =>'same-origin'}选项的fetch()API。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM