如何使用 Django 活塞身份验证会话?

发布于 2024-08-29 23:34:12 字数 214 浏览 2 评论 0原文

问题是我想将身份验证存储在一个 cookie 中,我可以将其呈现给 django 活塞,而不是要求每次都输入用户/密码(无需硬编码或将用户/密码组合存储在磁盘上的某个位置)。我希望能够像没有活塞 API 的人那样使用 cookie 来完成此任务。我错过了什么吗?

Django Piston 似乎根本不关心会话cookie?

或者有人可以建议一个好的选择吗?也许我不应该使用活塞?

The problem is that I want to store authentication in a cookie that I can present to django piston rather than requiring user/password to be typed in each time (without hardcoding or storing the user/pass combo somewhere on disk). I was hoping to accomplish this with cookies like someone would without the piston API. Am I missing something?

Django Piston doesn't seem to care about session cookies at all?

Or can someone suggest a good alternative? Maybe I shouldn't use Piston?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

野却迷人 2024-09-05 23:34:12

如果您尝试让用户在身份验证后保持登录状态,Django 的内置会话会为您做到这一点。您可以通过更改 来更改会话持续时间SESSION_COOKIE_AGE 设置。这也将改变会话在数据库中保留的时间(如果您使用的是数据库后端)。

If you are trying to keep a user logged in after they authenticate, Django's built in Sessions do that for you. You can change how long the session lasts by changing the SESSION_COOKIE_AGE setting. This will also change how long the sessions persist in your database (if you are using a database backend).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文