Instead of creating a cookie manually, you can save 4 lines and use the .set_cookie()[1] method on the response object.
Also, take a look at the render()[2] shortcut function to collapse the template loading, context settings, and rendering steps into one.
[1]: https://docs.djangoproject.com/en/1.3/ref/request-response/#... [2]: https://docs.djangoproject.com/en/1.3/topics/http/shortcuts/...