Safari 未设置发布请求中的 cookie

问题描述 投票:0回答:1

嗨,我使用 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 设置更改了使用响应对象玩的同一个站点,但没有任何效果。

django google-chrome safari
1个回答
0
投票

删除 secure=true 终于成功了

© www.soinside.com 2019 - 2024. All rights reserved.