title: Django: Properly Setting Cookies For Login
body: <p>I am new to Django's sessions, and i tried to make a login cookie for my website. User's on my website register via social website ( steam in this case ), For that i have different functions: <code>Index</code> view, Login, <code>LoginProcess</code>.</p>
  
  <h1>Information:</h1>
  
  <p><code>Index</code> view is a homepage (<code>127.0.0.1</code>), <code>Login</code> function redirects user to <code>LoginProcess</code>, in this process, i have set a cookie.</p>
  
  <pre><code>request.set_cookie(key='logged', value=True)
  </code></pre>
  
  <p><code>request</code> is instance that all 3 functions have in my code, I have set the logged in key to True, which should be read by Index function.</p>
  
  <p>Index Function:</p>
  
  <pre><code>def index(request):
      if request.COOKIES.get('logged') == True:
          return HttpResponse("1 - User is logged in")
      else:
          return HttpResponse("0 - User is not logged in)
  </code></pre>
  
  <p>Unfortunately, this brings up statement 0 (User is not logged in), even if i am logged in the website, the value of logged key is <code>None</code>.</p>
  
  <hr>
  
  <h1>Problem:</h1>
  
  <p><code>Index</code> function cannot detect that <code>logged</code> cookie was registered in <code>LoginProcess</code> function.</p>
  
  <h1>Question:</h1>
  
  <p>I am going to save the username in cookie as well, so system can determine which users data should it use, i know it is very bad for the client-side cookies, What's the best way of doing it?</p>
  
  <p>How could i fix this problem? Is there any better way to set up login cookie? Is there any other better way to set up login session? </p>
  
  <p>So basically, how could i set cookie in the first function and get it's value from the second function? </p>
  
  <p><strong>Note</strong>: There is no problem with authentication, my main concerns are to properly set cookies.</p>