title: Prevent multiple logins using the same credentials
body: <p>I checked previously asked similar Questions, but I am not able to find a suitable answer.</p>
  
  <p>Requirement: On two different machines the same user credentials can't be used to access the application.</p>
  
  <p>What I have implemented, At the time of login, logout from all previous devices used by user.</p>
  
  <pre><code>from django.contrib.auth.signals import user_logged_in
  
  class UserAccount(models.Model):
      """
      This model will be used to extra user information.
      """
  
      user = models.OneToOneField(User, db_index=True)
      session = models.CharField(max_length=40, null=True)
      ip_address = models.IPAddressField()
  
  def logout_other_devices(user, request, **kwargs):
      """
      Delete session(logout all) other devices with same credential.
      """
  
      profile = user.useraccount
  
      if profile.session:
          Session.objects.filter(session_key=profile.session).delete()
  
      profile.session = request.session.session_key
      profile.ip_address = request.META.get('REMOTE_ADDR')
      profile.save()
  
  
  user_logged_in.connect(logout_other_devices)
  </code></pre>
  
  <p>What still is left, if one user is logged in one system and passes its <code>sessionid</code> (from cookies) to the second user connected under the same WiFi(or LAN) connection then the IP of second is coming same on server. How can I discriminate the second user and log-out the first user before allowing access to any website data to the second user.</p>