Blog Archive for August 13, 2011

Django Cookies

August 13, 2011

It's easy to write and consume cookies in Django.

To set a cookie:

lResponse = render_to_response(pTemplate, 
                                  pParams, 
                                  context_instance=RequestContext(request))
lResponse.set_cookie("name_to_set", "value_to_set")

to read a cookie back in a view:

lCookieValue = request.COOKIES['name_to_set"]