如何在django中设置登录cookie? [英] How to set a login cookie in django?

查看:403
本文介绍了如何在django中设置登录cookie?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用登入我的网站的会员的使用者名称set_cookie?



感谢

会话中间件,请确保在项目中启用它。我建议您使用 django.contrib.auth 管理会话。它管理数据库中的会话,这比在cookie


中保存用户名要安全得多

How do I set_cookie with the username of the member that is logged in to my site?

Thanks

解决方案

you can implement this by using the session middleware, make sure to enable it in your project. I recommend you to use django.contrib.auth to manage sessions though. It manages sessions in the database which is a lot safer than just saving the username in a cookie

这篇关于如何在django中设置登录cookie?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆