Search code examples
djangocookiesauthenticationmember

How to set a login cookie in django?


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

Thanks


Solution

  • 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