[Django]-How to set Secure Cookie on WSGI applications in python

6👍

The Response.set_cookie function accepts an optional secure parameter. Example:

>>> res.set_cookie('key', 'value', max_age=360, path='/',
...                domain='example.org', secure=True)
>>> res.headers['Set-Cookie']
'key=value; Domain=example.org; Max-Age=360; Path=/; expires=... GMT; secure'

You can use secure=True in case you use HTTPS.

See here for more details.

Leave a comment