Entries published on December 22, 2023
Set cookies the right way
This is part of a series of posts I’m doing as a sort of Python/Django Advent calendar, offering a small tip or piece of information each day from the first Sunday of Advent through Christmas Eve. See the first post for an introduction.
Cookies in the cookie jar
Django’s request and response objects, and their attributes and methods, make dealing with cookies easy. You can read from the request.COOKIES
dictionary to get a cookie, and you can use the response’s set_cookie()
method to set cookies. What else do you need?
Well, potentially a few things.
First of all, it’s worth reviewing …