title: cookies not working in django
body: <p>I have to set cookies to save cart details in my project but its not working, when i test cookies using function</p>
  
  <pre><code>request.session.set_test_cookie()
  </code></pre>
  
  <p>Then it set cookies but response.set_cookie function is not setting cookies. I have tried this code.</p>
  
  <pre><code>def index(request):
      if request.method == 'GET':
          response = HttpResponse('hello')
          days_expire = 7
          max_age = days_expire * 24 * 60 * 60 
          response.set_cookie('my_cookie', 'Product Cart', max_age=max_age)
          return render(request, 'home/index.py')
  </code></pre>
  
  <p>and for getting cookis , this code is being used</p>
  
  <pre><code>def sport(request):
      if request.method == 'GET':
          if 'my_cookie' in request.COOKIES:
              value = request.COOKIES['my_cookie']
              return HttpResponse(value)
          else:
              return HttpResponse('Cookie not set')
  </code></pre>
  
  <p>It always prints cookie not set string, What can be the reason behind it.</p>