title: Django: Strategies for tracking and displaying users data
body: <h1>Details</h1>
  
  <p>I have made my custom authentication process for the users, (no, i didn't use django's dedicated authentication), I almost finished it, but still having concerns on the most important part at the time.</p>
  
  <p>so these are main parts of authentication process:</p>
  
  <ol>
  <li>User sign's into the website via steam's social authentication.</li>
  <li>My authentication system checks if database contains user's data, if not it will create a new user object with all the information.</li>
  <li>System will create cookie as key <code>logged</code> with the value of True.</li>
  </ol>
  
  <p>After these steps, there begins a problem, website should show users data when <code>logged</code> cookie's value is True.</p>
  
  <h1>Strategies and Questions</h1>
  
  <p>So as example, let's take stackoverflow, as i see: when it's login cookie is activated, it show's me my profile picture, and my score.</p>
  
  <p>How did it know that i was that specific user?</p>
  
  <p><strong>via cookies</strong>:</p>
  
  <p>If i tracked users data via cookies, i know that it would be a very bad idea since they are super-easy to change.</p>
  
  <p><strong>via ip address</strong>:</p>
  
  <p>Then there's a second way, to track them with ip address, which i don't think is a good idea:</p>
  
  <pre><code>from .models import User, IPs
  
  from django.http import HttpResponseRedirect, HttpResponse
  
  import steamapi
  
  def index(request, self):
      ip = request.META['HTTP_X_FORWARDED_FOR'] 
      for search in IPs.objects.all():
          if str(ip) in str(search):
              break
              user = ip.strip(ip) # model will contain ip address with username. e.g ( user 127.0.0.1 ), so i strip the ip
          else:
              username = steamapi.user.SteamUser(self.steamid) # i get steamid from different function which is not important.
              username = IPs(data=username + " " + ip)
              username.save()
      print request.COOKIES
      if request.COOKIES.get('logged'):
          return HttpResponse("User %s" + "is logged in" % username)
      else:
          response = HttpResponse("User is not logged in")
          response.set_cookie('logged', True)
          return response
  </code></pre>
  
  <p><strong>via sessions</strong>:</p>
  
  <p>I don't exactly know Django's sessions (except cookies), would it be good if i used django's cached sessions? if so how?</p>
  
  <p><strong>Note</strong>: i am looking for the code that will fit to my steps at beginning, so code example would be excellent.</p>
  
  <hr>
  
  <p>First strategy is totally bad idea, i think second is not pythonic and is not a good strategy, Third however, is one i need a help with.</p>
  
  <h1>General Question:</h1>
  
  <p>So what would best strategy be for displaying specific users data on the website? As i mentioned simillar to stackoverflow's bar, where it displays my profile picture and score.</p>