title: how do i stop multiple user login with same email and password once user already logged
body: <p>i need help how do i stop multiple user login with same email and password once the user already logged into the website i have website but in my website i have two kinds of membership subscription <code>free or paid</code> free users can try to login from multiple device's or pc's or browsers no problem with free users.</p>
  
  <p>but now problem is that i want to restrict the paid users because paid users shouldn't only login from multiple devices or pc or browser after paid user login from anywhere .. while paid user try to login then system should automatically logout paid user from previous browser or devices or pc?</p>
  
  <p><strong>Example*</strong></p>
  
  <pre><code>if paid user already login from chrome and user trying to login from firefox
  then system should automatically destroy first session which is created 
  from chrome. then allow paid users to use their account in firefox.
  </code></pre>
  
  <p><strong>Here My Test Script</strong></p>
  
  <p><strong>Index.php</strong></p>
  
  <pre><code>&lt;form action="verifylog.php" method="post"&gt;
  &lt;input type="text" name="email1" /&gt;&lt;br /&gt;
  &lt;input type="password" name="password1" /&gt;&lt;br /&gt;
  &lt;input type="submit" value="Submit" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>Verifylog.php</strong></p>
  
  <pre><code>session_start();
  include('config.php');
  if(empty($_POST['email1']))
  {
  header('Location:index.php');   
  }
  $email=$_POST['email1'];
  $password=$_POST['password1'];
  
  $querymysql=mysql_query("select * from users where uemail='$email' 
  and upass='$password'") or die ("query problem");
  
  $row=mysql_fetch_array($querymysql);
  $db_email1=$row['uemail'];
  $db_pass=$row['upass'];
  $db_status=$row['ustatus'];
  
  if($row&gt;0){
  
  $_SESSION['new_email']=$db_email1;
  $_SESSION['new_pass']=$db_pass;
  $_SESSION['new_status']=$db_status;
  
  $_SESSION['logged_in'] = 'active';
  
  if(isset($_SESSION['logged_in']) || !empty($_POST['email1']) )
  {
  
  $query_time=mysql_query("UPDATE users SET ustatus='".$_SESSION['logged_in']."'
  WHERE uemail='".$email."'");
  
  header('Location:test.php');
  
  }
  }
  
  if($db_status==$_SESSION['logged_in'])
  {
  header("location:logout.php");  
  }
  else 
  {
  $msg="please check your email and password";    
  $_SESSION['error_msg']=$msg;
  header('Location:index.php?error='.$_SESSION['error_msg'].'');
  
  }
  </code></pre>
  
  <p><strong>Test.php</strong></p>
  
  <pre><code>&lt;?php 
  $querymysql=mysql_query("select * from users 
  where  uemail='".$_SESSION['new_email']."'") or die ("query problem");
  $row=mysql_fetch_array($querymysql);
  ?&gt;
  
  Hello Mr. &lt;?php echo $row['uemail']; ?&gt; &lt;br /&gt;
  Your Email Is &amp;nbsp; &lt;?php echo $row['uemail']; ?&gt; &lt;br /&gt;
  Your Password Is &amp;nbsp; &lt;?php echo $row['upass']; ?&gt; &lt;br /&gt;
  Your Status Is &amp;nbsp; &lt;?php echo $row['ustatus']; ?&gt; &lt;br /&gt;
  Here Your Can Logout Your Account: &lt;a href="logout.php"&gt;Click Here&lt;/a&gt;
  </code></pre>
  
  <p><strong>Logout.php</strong></p>
  
  <pre><code>&lt;?php 
  session_start();
  include('config.php');
  
  if(!empty($_SESSION['logged_in']) || !empty($_POST['email1']) )
  {
  session_destroy();
  $query_time=mysql_query("UPDATE users SET ustatus='inactive' 
      WHERE uemail='".$_SESSION['new_email']."'");
  
  header("location:index.php");
  }
  ?&gt;
  </code></pre>
  
  <p><strong>Thank You All I Have Completed My Script</strong></p>
  
  <p><strong>Here My Completed If Any Web Developer Need It</strong></p>
  
  <pre><code>how to prevent multiple user login with same email and password once user 
  already logged from multiple pc or browsers
  </code></pre>
  
  <p><strong>Index.php</strong></p>
  
  <pre><code>&lt;form action="verifylog.php" method="post"&gt;
  &lt;input type="text" name="email1" /&gt;&lt;br /&gt;
  &lt;input type="password" name="password1" /&gt;&lt;br /&gt;
  &lt;input type="submit" value="Submit" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>Verifylog.php</strong></p>
  
  <pre><code>session_start();
  include('config.php');
  if(empty($_POST['email1']))
  {
  header('Location:index.php');   
  }
  $email=$_POST['email1'];
  $password=$_POST['password1'];
  
  $querymysql=mysql_query("select * from users where uemail='$email' 
  and upass='$password'") or die ("query problem");
  $row=mysql_fetch_array($querymysql);
  
  $db_email1=$row['uemail'];
  $db_pass=$row['upass'];
  $db_status=$row['ustatus'];
  $db_sessionid=$row['session_id'];
  
  
  $old_sessionid = session_id();
  $new_sessionid = session_regenerate_id(true);
  $_SESSION['newregid']=$new_sessionid;
  $_SESSION['odlregid']=$old_sessionid;
  
  $_SESSION['new_email']=$db_email1;
  $_SESSION['new_pass']=$db_pass;
  $_SESSION['new_status']=$db_status;
  
  
  if(!empty($old_sessionid))
  {
  
  $query_time=mysql_query("UPDATE users SET session_id='".$old_sessionid."' 
  WHERE uemail='".$email."'");
  
  header('Location:test.php');
  }
  
  else if($db_sessionid!=$_SESSION['odlregid'])
  {
  
  $query_time=mysql_query("UPDATE users SET session_id='".$new_sessionid."' 
  WHERE uemail='".$email."'");
  header('Location:test.php');
  }
  </code></pre>
  
  <p><strong>Test.php</strong></p>
  
  <pre><code>&lt;?php 
  $querymysql=mysql_query("select * from users 
      where uemail='".$_SESSION['new_email']."'") or die ("query problem");
  $row=mysql_fetch_array($querymysql);
  $new_id=$row['session_id'];
  
  if($new_id!=$_SESSION['odlregid']){
  
  unset($_SESSION['odlregid']);
  session_destroy();
  header("location:index.php");
  
  } else { ?&gt;
  
  Hello Mr. &lt;?php echo $row['uemail']; ?&gt; &lt;br /&gt;
  Your Email Is &amp;nbsp; &lt;?php echo $row['uemail']; ?&gt; &lt;br /&gt;
  Your Password Is &amp;nbsp; &lt;?php echo $row['upass']; ?&gt; &lt;br /&gt;
  Your Status Is &amp;nbsp; &lt;?php echo $row['ustatus']; ?&gt; &lt;br /&gt;
  Your Session_Id Is &amp;nbsp; &lt;?php echo $row['session_id']; ?&gt; &lt;br /&gt;
  Here Your Can Logout Your Account: &lt;a href="logout.php"&gt;Click Here&lt;/a&gt;
  
  &lt;?php }?&gt;
  </code></pre>
  
  <p><strong>Logout.php</strong></p>
  
  <pre><code>    &lt;?php 
  session_start();
  include('config.php');  
  header("location:index.php");   
  ?&gt;
  </code></pre>