我有两台服务器:
服务器1在端口http://test_subdomain.maindomain.com:8000上运行,服务器2在http://test_subdomain.maindomain.com:5000上运行
我面临的问题是cookie不会持久存在多个ajax调用,这意味着我无法让用户保持登录状态。
当我尝试从其他客户端登录到服务器2时,这是我的回复:
HTTP/1.1 200 OK
Server: gunicorn/19.6.0
Content-Type: application/json
Set-Cookie: session=.eJwdjsFqwzAQRH-l7DkHW1Ivhh5apAYHdkWMqNBeAq3d2JJ9cRKSKuTfq_Y0MMx7zB0O3-twGqE5r5dhA4eph-YOT5_QgNWvMoj2mcResTMyuN2Empbgu8SOE8UukUOJwkj0PFLZsg4_lCnxNtxIf0nrOVnfKo7vS-mq4I6ChKnR04QiVH8ezG1N2dwo92PJK7s-oe5m0kdFeZw57orPFPYtsttX1n9MrCnhEmrWc7Rb8wKPDVxOw_r_H4QSCh6_CwZGAA.DGSLDw.vpI20IaG1fJkABGOcr77ZyP3BQc; Path=/
Access-Control-Allow-Origin: *
Date: Thu, 03 Aug 2017 10:23:11 GMT
Content-Length: 161
Connection: close
{
"user": {
"id": 2424,
"name": "Xyz",
"profile_picture": null,
"referralBonus": null,
"referralCode": null,
"wallet": null
}
}
来自Google Chrome,它是:
Request URL:http://test_subdomain.maindomain.com:5000/login
Request Method:POST
Status Code:200 OK
Remote Address:666.666.666.666:5000
Referrer Policy:no-referrer-when-downgrade
Access-Control-Allow-Origin:http://test_subdomain.maindomain.com:8000
Connection:close
Content-Length:161
Content-Type:application/json
Date:Thu, 03 Aug 2017 10:24:51 GMT
Server:gunicorn/19.6.0
Set-Cookie:session=.eJwdjsGKg0AQRH9l6XMORvQi5CIjAaFbsowJ05fAGpNxnLmYFU0H_31nc6jLK6hXb7jep_5pofid5n4H1-EGxRu-fqAAo1thfVpNMHmj7MCKhkZ7j0eyKI_EaI4MBaW0qNuFQpWg6xZ2laBrc0zNGvsc5WxRxUj34uM_KwdKK-FQW3a4J-kW0uWIDhNWp4w-PvKovkcjZsVAniQ6LzzGzay51B7dzZvAAUMdSD8OsO1gfvbT5z-kWZrB9gcA-km6.DGSLcw.RltIYqt4y6E76lKVWI-H9PXMz58; Path=/
Vary:Origin
Accept:application/json, text/javascript, */*; q=0.01
Accept-Encoding:gzip, deflate
Accept-Language:en-US,en;q=0.8
Cache-Control:no-cache
Connection:keep-alive
Content-Length:46
Content-Type:application/json
Host:test_subdomain.maindomain.com:5000
Origin:http://test_subdomain.maindomain.com:8000
Pragma:no-cache
Referer:http://cookie.beatest.in:8000/
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36
我做错了什么?我试过这个多个浏览器,但没有一个可以工作。任何浏览器的cookie中都没有设置cookie