1

i need help to completed my login script and but i'm confused how to prevent user multiple login with single account?

in my website i have membership subscription one is free and another is one paid but i want to create more secure login system and also i want embed this function that paid user can't be login from multiple pc or browser once user already logged from single account.

Example Of System

1)if user login from google chrome and trying to login from firfox then system should automtically destroy      chrome session? 

Here My Login Script

$email=$_POST['email'];
$password=$_POST['password'];
$email = stripslashes($email);
$password= stripslashes($password);
$email = mysql_real_escape_string($email);
$password = mysql_real_escape_string($password);


//selecting user from db
$querymysql=mysql_query("select * from students where semail='$email'
and spassword='$password'") or die ("query problem");

$row=mysql_fetch_array($querymysql);
$name=$row['sname'];
$act=$row['activation'];
$e=$row['semail'];
$p=$row['spassword'];
$ss=$row['sstatus'];

if($row>0){

if($row['sstatus']=="allow")
{   
if($row["activation"]=="activated")
{

$_SESSION['logclass']=$row['sclass'];
$_SESSION['logname']=$row['sname'];
$_SESSION['logsid']=$row['sid'];        
$_SESSION['logemail']=$row['semail'];   
$_SESSION['logclass']=$row['sclass'];
$_SESSION['logsubscribe']=$row['subscribe'];


$_SESSION['logged']=$row['loginstatus'];

$_SESSION['logged_in'] = true;

if(isset($_SESSION['logged_in']))
{
$query_time=mysql_query("UPDATE students SET loginstatus='".$_SESSION['logged_in']."'
WHERE semail='".$email."'");
header('Location:users/dashboard/index.php');
}

}
if($login1==$_SESSION['logged_in'])
{
header("location:logout.php");  
}


}else if ($row["activation"]!="activated")
{
$actmsg="text"; 
header('Location:login.php?actmsg='.$actmsg.'');
}
}
else 
{
$pending="Your Account Is Not Approved By Admin";   
header('Location:login.php?pending='.$pending.'');  
}
}

else
{
$message="Please Check Your Login Details"; 
header('Location:login.php?login_error='.$message.'');  
}
  • put a flag in table and use it – ɹɐqʞɐ zoɹǝɟ Jun 26 '14 at 08:08
  • you need to store the fact that the user is logged in in the database. If the user tries to login again, check the database to see if he's already logged in. – Barmar Jun 26 '14 at 08:10
  • @Barmar i have updated my script and insert login status when user login but now how do i check same user trying to login from another browser? or device? –  Jun 26 '14 at 08:23

0 Answers0