嗨,我使用django作为服务器端,我设置了带有重定向请求的cookie,但它不起作用,我试图只发送一个请求,但cookie仍然不起作用。
response = HttpResponse('ok')
expires = datetime.datetime.now() + expires_in
response.set_cookie(key='session_cookie', value=session_cookie, expires=expires, samesite='Lax',httponly=True, secure=True)
return response
字符串
这里是http响应
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
X-Content-Type-Options: nosniff
Set-Cookie: session_cookie=eyJhbGciOiJSUzI1NiIsImtpZCI6InRCME0yQSJ9.eyJpc3MiOiJodHRwczovL3Nlc3Npb24uZmlyZWJhc2UuZ29vZ2xlLmNvbS9tYW5pYWt1dyIsImFkbWluIjp0cnVlLCJhdWQiOiJtYW5pYWt1dyIsImF1dGhfdGltZSI6MTY4ODkxNDY5NiwidXNlcl9pZCI6InJXZkRRMk1vS0VidDkyRDhrdERsYVh4NVJUSDMiLCJzdWIiOiJyV2ZEUTJNb0tFYnQ5MkQ4a3REbGFYeDVSVEgzIiwiaWF0IjoxNjg4OTE0NzAyLCJleHAiOjE2ODkzNDY3MDIsImVtYWlsIjoib3NhbWF0YW1lcjM5MEBnbWFpbC5jb20iLCJlbWFpbF92ZXJpZmllZCI6ZmFsc2UsImZpcmViYXNlIjp7ImlkZW50aXRpZXMiOnsiZW1haWwiOlsib3NhbWF0YW1lcjM5MEBnbWFpbC5jb20iXX0sInNpZ25faW5fcHJvdmlkZXIiOiJwYXNzd29yZCJ9fQ.lUqDQBuRlJ2I8i7Da0zaDUQ8Bcih8Rr1oBzANINyi2Sde9yIZWE7VPx3ZSCizQHAnKRhjziSJBNN54dBIhdJk5Ps2yfHvUQaiaW7BhSmCu-K20Uvy3xv7HHoHaAKradSJXGM9Cs8a7t3PsAqQLroCbjFwmSsr31FpVxyrSueuAmrYedPkX0jz2XB3uanvl1FBYy1wx1Wrc_WbVs8DJCtpv1zTndOjDBxJvu0r2qIi7nc90EtPqfr0N6mKtPXn5pEJTdQ16f_O4-diuJbUsS7ivtWe9IFQPGWur9KaG6FpOngpWGpoJuDm0k2ReOaVQfQVLeJ46dTc6MzB7kEnLh4hg; expires=Fri, 14 Jul 2023 14:58:22 GMT; HttpOnly; Max-Age=432000; Path=/; SameSite=Lax; Secure, sessionid=tcbhtb1kfxu2p939j1g00ewsssyr0zx8; expires=Sun, 23 Jul 2023 14:58:22 GMT; HttpOnly; Max-Age=1209600; Path=/; SameSite=Lax; Secure
Date: Sun, 09 Jul 2023 14:58:22 GMT
X-Frame-Options: SAMEORIGIN
Cross-Origin-Opener-Policy: same-origin
Content-Length: 2
Referrer-Policy: same-origin
Vary: origin, Cookie
Server: WSGIServer/0.2 CPython/3.9.6
型
在chrome中一切都正常工作。
我试着玩cookie设置改变了相同的网站玩响应对象没有工作。
1条答案
按热度按时间5m1hhzi41#
删除secure=true终于成功了