title: How to set cookie in Django and then render template?
body: <p>I want to set a cookie inside a view and then have that view render a template.  As I understand it, this is the way to set a cookie:</p>
  
  <pre><code>def index(request):
      response = HttpResponse('blah')
      response.set_cookie('id', 1)
      return response
  </code></pre>
  
  <p>However, I want to set a cookie and then render a template, something like this:</p>
  
  <pre><code>def index(request, template):
      response_obj = HttpResponse('blah')
      response_obj.set_cookie('id', 1)
      return render_to_response(template, response_obj)   # &lt;= Doesn't work
  </code></pre>
  
  <p>The template will contain links that when clicked will execute other views that check for the cookie I'm setting.  What's the correct way to do what I showed in the second example above?  I understand that I could create a string that contains all the HTML for my template and pass that string as the argument to HttpResponse but that seems really ugly.  Isn't there a better way to do this?  Thanks.</p>