Page 1 of 1

Restricting multiple logins

Posted: Thu Jul 14, 2005 11:54 pm
by vivekjain
Hi,
We are developing an application using PHP, MySQL. We would want to restrict multiple users logging in using the same username and password, at the same time. i.e., if I have logged in using the username and pwd: admin, and at the same time someone else uses that username and pwd, it should restrict. One of the ways we thought was, to set a flag as logged in when the first users logs in, so whenever any one else tries to log, based on the flag setting it will restrict. But now, if the first user closes the browser without logging out, then the flag remains as logged in the db and no one else can log in from there. How can we take care of this? Any help on this would be appreciated. Thanks

Posted: Fri Jul 15, 2005 1:07 am
by Burrito
you could stamp the time when they log in and then update it for every page that is hit. You'd have to set an expiration time so that if they didn't log out, it would expire after 5 minutes (example) and then someone else could log in using their credentials or they could log back in from the same machine and be given a new id/key for their session. The only problem with this scenario is that if they are inactive for the specified time the other person could log in and steal their session.

I guess a way around that would be to check the previous id/key and give it priority over any subsequent ones generated.

there might be another/better way to do this, but I don't know of any as most web apps stateless.
8O

Posted: Fri Jul 15, 2005 1:12 am
by s.dot
You could include a field in your database that records the time a user was last active on the site. Perhaps on every page load, run a query to update this field.

Then determine if they are 'logged on' as say.. 15 minutes of time with no activity?

When you go to log on, query the database like

Code: Select all

$query = mysql_query("SELECT id FROM table WHERE username = '".$_POST['username']."' AND timelastactive >= '".time()-300."'");

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
     die("User ".$_POST['username']." is already logged into the system.");
}
This is about the only way to do it since PHP is server side, and there's not a way to tell what the user is actually doing (client side).ecords the time a user was last active on the site. Perhaps on every page load, run a query to update this field.

Then determine if they are 'logged on' as say.. 15 minutes of time with no activity?

When you go to log on, query the database like

Code: Select all

$query = mysql_query(&quote;SELECT id FROM table WHERE username = '&quote;.$_POSTї'username'].&quote;' AND timelastactive >= '&quote;.time()-300.&quote;'&quote;);

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
     die(&quote;User &quote;.$_POSTї'username'].&quote; is already loggn the site.  Perhaps on every page load, run a query to update this field.

Then determine if they are 'logged on' as say.. 15 minutes of time with no activity?

When you go to log on, query the database like

Code: Select all

$query = mysql_query(&quote;SELECT id FROM table WHERE username = '".$_POST['username'].&quote;' AND timelastactive >= '&quote;.time()-300.&quote;'&quote;);

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) &amto update this field.

Then determine if they are 'logged on' as say.. 15 minutes of time with no activity?

When you go to log on, query the database like

Code: Select all

$query = mysql_query("SELECT id FROM table WHERE username = '&quote;.$_POSTї'username'].&quote;' AND timelastactive >= '&quote;.time()-300.&quote;'&quote;);

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
     die(&quote;User &e load, run a query to update this field.

Then determine if they are 'logged on' as say.. 15 minutes of time with no activity?

When you go to log on, query the database like

Code: Select all

$query = mysql_query("SELECT id FROM table WHERE username = '".$_POST['username']."' AND timelastactive >= '".time()-300."'");

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
     die("User ".$a field in your database that records the time a user was last active on the site.  Perhaps on every page load, run a query to update this field.

Then determine if they are 'logged on' as say.. 15 minutes of time with no activity?

When you go to log on, query the database like

Code: Select all

$query = mysql_query("SELECT id FROM table WHERE username = '".$_POST['username']."' AND timelastactive >= '".time()-300."'");

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
     die("User ".$_POST['username']." is already logged into the system.");
}
This is about the only way to do it since PHP is server side, and there's not a field in your database that records the time a user was last active on the site. Perhaps on every page load, run a query to update this field.

Then determine if they are 'logged on' as say.. 15 minutes of time with no activity?

When you go to log on, query the database like

Code: Select all

$query = mysql_query("SELECT id FROM table WHERE username = '".$_POST['username']."' AND timelastactive >= '".time()-300."'");

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
     die("User ".$_POST['username']." is already logged into the system.");
}
This is about the only way to do it since PHP is server side, and there's not a way to tell what the user is actually doing (client side).ry) > 0)
{
die("User ".$_POST['username']." is already logged into the system.");
}

This is about the only way to do it since PHP is server side, and there's not a way to tell what the user is actually doing (client side).ere's not a way to tell what the user is actually doing (client side).on the site. Perhaps on every page load, run a query to update this field.

Then determine if they are 'logged on' as say.. 15 minutes of time with no activity?

When you go to log on, query the database like

Code: Select all

$query = mysql_query("SELECT id FROM table WHERE username = '".$_POST['username']."' AND timelastactive >= '".time()-300."'");

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
     die("User ".$_POST['username']." is already logged into the system.");
}
This is an every page load, run a query to update this field.

Then determine if they are 'logged on' as say.. 15 minutes of time with no activity?

When you go to log on, query the database like

Code: Select all

$query = mysql_query("SELECT id FROM table WHERE username = '".$_POST['username']."' AND timelastactive >= '&quote;.time()-3he time a user was last active on the site.  Perhaps on every page load, run a query to update this field.

Then determine if they are 'logged on' as say.. 15 minutes of time with no activity?

When you go to log on, query the database like

Code: Select all

$query = mysql_query("SELECT id FROM table WHERE username = '".$_POST['username']."' AND timelastactive >= '&quote;.time()-300.&quote;'&quote;);

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
     die("User ".$_POST['username']." is already logged into the system.");
}
This is about the only way to do it since PHP is server side, and there's not a way to tell what the user is actually doing (client side).say.. 15 minutes of time with no activity?

When you go to log on, query the database like

Code: Select all

$query = mysql_query("SELECT id FROM table WHERE username = '".$_POST['username']."' AND timelastactive >= '".time()-300."'");

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
     die("User ".$_POST['username']." is already logged into the system.");
}
This is about the only way to do it since PHP is server siable WHERE username = '".$_POST['username']."' AND timelastactive >= '".time()-300."'");

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
die("User ".$_POST['username']." is already logged into the system.");
}

This is about the only way to do it since PHP is server side, and there's not a way to tell what the user is actually doing (client side).ur database that records the time a user was last active on the site. Perhaps on every page load, run a query to update this field.

Then determine if they are 'logged on' as say.. 15 minutes of time with no activity?

When you go to log on, query the database like

Code: Select all

$query = mysql_query("SELECT id FROM table WHERE username = '".$_POST['username']."' AND timelastactive >= '".time()-300."'");

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
     die("User ".$_POST['username']." is already logged into the system.");
}
This is about the only way to do it since PHP is server side, and there's not a way to tell what the user is actually doing (client side).log on, query the database like

Code: Select all

$query = mysql_query("SELECT id FROM table WHERE username = '".$_POST['username']."' AND timelastactive >= '".time()-300."'");

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
     die("User ".$_POST['username']." is already logged into the system.");
}
This is about the only way to do it since PHP is server side, and there's not a way to tell what the user is actualamp;quote;.$_POST['username']."' AND timelastactive >= '".time()-300."'");

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
die("User ".$_POST['username']." is already logged into the system.");
}

This is about the only way to do it since PHP is server side, and there's not a way to tell what the user is actually doing (client side).
This is about the only way to do it since PHP is server side, and there's not a way to tell what the user is actually doing (client side).utes of time with no activity?

When you go to log on, query the database like

Code: Select all

$query = mysql_query("SELECT id FROM table WHERE username = '".$_POST['username']."' AND timelastactive >= '".time()-300.&quote;'&quote;);

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
     die(&quote;User &quote;.$_POSTї'username'].&quote; is already logge like

Code: Select all

$query = mysql_query("SELECT id FROM table WHERE username = '".$_POST['username']."' AND timelastactive >= '".time()-300."'");

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
     die("User ".$_POST['username']." is already logged into the system.");
}
This is about the only way to do it since PHP is server side, and there's not a way to tell what the user is actually doing (client side).y was met
if(mysql_num_rows($query) > 0)
{
die("User ".$_POST['username']." is already logged into the system.");
}

This is about the only way to do it since PHP is server side, and there's not a way to tell what the user is actually doing (client side).a field in your database that records the time a user was last active on the site. Perhaps on every page load, run a query to update this field.

Then determine if they are 'logged on' as say.. 15 minutes of time with no activity?

When you go to log on, query the database like

Code: Select all

$query = mysql_query("SELECT id FROM table WHERE username = '".$_POST['username']."' AND timelastactive >= '".time()-300."'");

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
     die("User ".$_POST['username']." is already logged into the system.");
}
This is about the only way to do it s' AND timelastactive >= '".time()-300."'");

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
die("User ".$_POST['username']." is already logged into the system.");
}

This is about the only way to do it since PHP is server side, and there's not a way to tell what the user is actually doing (client side). records the time a user was last active on the site. Perhaps on every page load, run a query to update this field.

Then determine if they are 'logged on' as say.. 15 minutes of time with no activity?

When you go to log on, query the database like

Code: Select all

$query = mysql_query("SELECT id FROM table WHERE username = '".$_POST['username']."' AND timelastactive >= '".time()-300."'");

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
     die("User ".$_POST['username']." is already logged into the system.");
}
This is about the only way to do it since PHP is server side, and there's not re 'logged on' as say.. 15 minutes of time with no activity?

When you go to log on, query the database like

Code: Select all

$query = mysql_query("SELECT id FROM table WHERE username = '".$_POST['username']."' AND timelastactive >= '".time()-300."'");

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
     die("User ".$_POST['username']." is already logged into the system.");
}
This is about the only way to do it since PHP is server side, and there's not a way to tell what the user is actually doing (client side).at records the time a user was last active on the site. Perhaps on every page load, run a query to update this field.

Then determine if they are 'logged on' as say.. 15 minutes of time with no activity?

When you go to log on, query the database like

Code: Select all

$query = mysql_query("SELECT id FROM table WHERE username = '".$_POST['username']."' AND timelastactive >= '".time()-300.&quote;'&quote;);

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
     die(&quote;User &quote;tivity?

When you go to log on, query the database like

Code: Select all

$query = mysql_query("SELECT id FROM table WHERE username = '".$_POST['username']."' AND timelastactive >= '".time()-300."'");

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
     die(&quote;User &quote;.$_POST['username']." is already logged into the system.");
}
T5 minutes of time with no activity?

When you go to log on, query the database like

Code: Select all

$query = mysql_query("SELECT id FROM table WHERE username = '".$_POST['username']."' AND timelastactive >= '".time()-300."'");

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
     die("User ".$_POST['username']." is already logged into the system.");
}
This is about the only way to do it since PHP is stactive >= '".time()-300."'");

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
die(&quote;User ".$_POST['username']." is already logged into the system.");
}

This is about the only way to do it since PHP is server side, d FROM table WHERE username = '".$_POST['username']."' AND timelastactive >= '".time()-300."'");

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
die("User ".$_POST['username']." is already logged into the system.");
}

This is about the only way to do it since PHP is server side, and there's not a way to tell whaps on every page load, run a query to update this field.

Then determine if they are 'logged on' as say.. 15 minutes of time with no activity?

When you go to log on, query the database like

Code: Select all

$query = mysql_query("SELECT id FROM table WHERE username = '".$_POST['username']."' AND timelastactive >= '".time()-300."'");

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
     die("User ".$_POST['username']." is already logged into the system.");
}
This is about the only way to do it since PHP is server side, and there's not a way to tell what the user is actually doing (client side). database that records the time a user was last active on the site. Perhaps on every page load, run a query to update this field.

Then determine if they are 'logged on' as say.. 15 minutes of time with no activity?

When you go to log on, query the database like

Code: Select all

$query = mysql_query("SELECT id FROM table WHERE username = '".$_POST['username']."' AND timelastactive >= '".time()-300."'");

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
     die("User ".$_POST['username']." is already logged into the system.");
}
This is about the only way to do it since PHP is server side, and there's not a way to tell what the user is actually doing (client side).uote;.$_POST['username']."' AND timelastactive >= '".time()-300."'");

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
die(&quote;User &quote;.$_POSTї'username'].&quote; is already logged into the system.");
}

a field in your database that records the time a user was last active on the site. Perhaps on every page load, run a query to update this field.

Then determine if they are 'logged on' as say.. 15 minutes of time with no activity?

When you go to log on, query the database like

Code: Select all

$query = mysql_query("SELECT id FROM table WHERE username = '".$_POST['username']."' AND timelastactive >= '".time()-300."'");

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
     die("User ".$_POST['username']." is already logged into the system.");
}
This is about the only way to do it since PHP is server side,. 15 minutes of time with no activity?

When you go to log on, query the database like

Code: Select all

$query = mysql_query("SELECT id FROM table WHERE username = '".$_POST['username']."' AND timelastactive >= '&quote;.time()-300.&quote;'&quote;);

// tser was last active on the site.  Perhaps on every page load, run a query to update this field.

Then determine if they are 'logged on' as say.. 15 minutes of time with no activity?

When you go to log on, query the database like

Code: Select all

$query = mysql_query(&quote;SELECT id FROM table WHERE username = '&quote;.$_POSTї'username'].&quote;' AND timelastactive >= '&quote;.time()-300.&quote;'&quote;);

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
     die(&quote;User &quote;.$_POSTї'username'].&quote; is already logged into the system.&quote;);
}
This is about the only way to do it since PHP is server side, and there's not a way to tell what the user is actually doing (client side)f they are 'logged on' as say.. 15 minutes of time with no activity?

When you go to log on, query the database like

Code: Select all

$query = mysql_query("SELECT id FROM table WHERE username = '".$_POST['username']."' AND timelastactive >= '".time()-300."'");

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
     die("User ".$_POST['username']." is already logged into the system.");
}
This is about the only way to do it since PHP is server side, and there's not a way to tell what the user is actually doing (client side).a field in your database that records the time a user was last active on the site. Perhaps on every page load, run a query to update this field.

Then determine if they are 'logged on' as say.. 15 minutes of time with no activity?

When you go to log on, query the database like

Code: Select all

$query = mysql_query("SELECT id FROM table WHERE username = '".$_POST['username']."' AND timelastactive >= '".time()-300."'");

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
     die("User ".$_POST['username']." is already logged into the system.");
}[/php:1:'logged on' as say.. 15 minutes of time with no activity?

When you go to log on, query the database like

Code: Select all

$query = mysql_query("SELECT id FROM table WHERE username = '".$_POSTї'username'].&quote;' AND timelastactive >= '&quote;.time()-300.&quote;'&quote;);

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
     die("User ".$_POST['username']." is already logged into the system.");
}
This is about the only way to do it since PHP is server side, and there's not d.

Then determine if they are 'logged on' as say.. 15 minutes of time with no activity?

When you go to log on, query the database like

Code: Select all

$query = mysql_query("SELECT id FROM table WHERE username = '".$_POST['username']."' AND timelastactive >= '".time()-300."'");

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
     die("User ".$_POST['username']." is already logged into the system.");
}
This is about the only way to do it since PHPnum_rows($query) > 0)
{
die("User ".$_POST['username']." is already logged into the system.");
}

This is about the only way to do it since PHP is server side, and there's not a way to tell what the user is actually doing (client side).POST['username']."' AND timelastactive >= '".time()-300."'");

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
die("User ".$_POST['username']." is already logged into the system.");
}

This is about the only way to do it since PHP is server side, and there's not a way to tell what the user is actually doing (client side).e if they are 'logged on' as say.. 15 minutes of time with no activity?

When you go to log on, query the database like

Code: Select all

$query = mysql_query("SELECT id FROM table WHERE username = '".$_POST['username']."' AND timelastactive >= '".time()-300."'");

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
     die("User ".$_POST['username']." is already logged into the system.");
}
This is about the only way to do it since PHP is server side, and there's not a way to tell what the user is actually doing (client side).a field in your database that records the time a user was last active on the site. Perhaps on every page load, run a query to update this field.

Then determine if they are 'logged on' as say.. 15 minutes of time with no activity?

When you go to log on, query the database like

Code: Select all

$query = mysql_query("SELECT id FROM table WHERE username = '".$_POST['username']."' AND timelastactive >= '".time()-300."'");

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
     die("User ".$_POST['username']." is already logged into the system.");
}
This is about the only way to do it since PHP is server side, and there's not a way to tell what the user is active on the site. Perhaps on every page load, run a query to update this field.

Then determine if they are 'logged on' as say.. 15 minutes of time with no activity?

When you go to log on, query the database like

Code: Select all

$query = mysql_query("SELECT id FROM table WHERE username = '".$_POST['username']."' AND timelastactive >= '&quote;.time()-300.& that records the time a user was last active on the site.  Perhaps on every page load, run a query to update this field.

Then determine if they are 'logged on' as say.. 15 minutes of time with no activity?

When you go to log on, query the database like

Code: Select all

$query = mysql_query("SELECT id FROM table WHERE username = '".$_POST['username']."' AND timelastactive >= '".time()-300."'");

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
     die("User &quote;.$_POSTї'username'].&quote; is already logged into the system.&quote;);
}
This is about the only way to do it since PHP is server side, and there's not a way to tell what the user is actually doing (client side). timelastactive >= '".time()-300."'");

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) &gn determine if they are 'logged on' as say.. 15 minutes of time with no activity?

When you go to log on, query the database like

Code: Select all

$query = mysql_query(&quote;SELECT id FROM table WHERE username = '&quote;.$_POSTї'username'].&quote;' AND timelastactive >= '&quote;.time()-300.&quote;'&quote;);

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
     die(&quote;User &quote;.$_POSTї'username'].&quote; is already logged into the sysoad, run a query to update this field.

Then determine if they are 'logged on' as say.. 15 minutes of time with no activity?

When you go to log on, query the database like

Code: Select all

$query = mysql_query("SELECT id FROM table WHERE username = '".$_POST['username']."' AND timelastactive >= '".time()-300."'");

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
     die("User ".$_POST['username']." is already logged into the system.");
}
This is about the only way to do it since PHP is server side, and there's not a way to tell what the user is actually doing (client side). records the time a user was last active on the site. Perhaps on every page load, run a query to update this field.

Then determine if they are 'logged on' as say.. 15 minutes of time with no activity?

When you go to log on, query the database like

Code: Select all

$query = mysql_query("SELECT id FROM table WHERE username = '".$_POST['username']."' AND timelastactive >= '".time()-300."'");

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
     die("User ".$_POST['username']." is already logged into the system.");
}[mine if they are 'logged on' as say.. 15 minutes of time with no activity?

When you go to log on, query the database like

Code: Select all

$query = mysql_query(&quote;SELECT id FROM table WHERE username = '&quote;.$_POSTї'username'].&quote;' AND timelastactive >= '&quote;.time()-300.&quote;'&quote;);

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
     die(&quote;User &quote;.$_POSTї'username'].&quote; is already lte.  Perhaps on every page load, run a query to update this field.

Then determine if they are 'logged on' as say.. 15 minutes of time with no activity?

When you go to log on, query the database like

Code: Select all

$query = mysql_query(&quote;SELECT id FROM table WHERE username = '&quote;.$_POST['username']."' AND timelastactive >= '".time()-300."'");

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
     die("User ".$_POST['username']." is already logged into the system.");
}
This is about the only way to do it since PHP is server side, and there's not a way to tell what the user is actually doing (client side).p;quote;' AND timelastactive >= '".time()-300."'");

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
die("User ".$_POST['username']." is already logged into the system.");
}

This is about the only way to do it since PHP is server side, and there's not a way to tell what the user is actually doing (client side).E username = '".$_POST['username']."' AND timelastactive >= '".time()-300."'&quote;);

// this example is y to update this field.

Then determine if they are 'logged on' as say.. 15 minutes of time with no activity?

When you go to log on, query the database like

Code: Select all

$query = mysql_query("SELECT id FROM table WHERE username = '".$_POST['username']."' AND timelastactive >= '".time()-300."'");

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
     die("User ".$_POST['username']." is already logged into the system.");
}
This is about the only way to do it since PHP is server side, and thereif they are 'logged on' as say.. 15 minutes of time with no activity?

When you go to log on, query the database like

Code: Select all

$query = mysql_query("SELECT id FROM table WHERE username = '".$_POST['username']."' AND timelastactive >= '".time()-300."'");

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
     die("User ".$_POST['username']." is already logged into the system.");
}
This is about the only way to do it since PHP is server side, and there's not a way to tell what the user is actually doing (client side).haps on every page load, run a query to update this field.

Then determine if they are 'logged on' as say.. 15 minutes of time with no activity?

When you go to log on, query the database like

Code: Select all

$query = mysql_query("SELECT id FROM table WHERE username = '".$_POST['username']."' AND timelastactive >= '".time()-300."'");

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
     die("User ".$_POST['username']." is already logged into the system.");
}
This is about the onle load, run a query to update this field.

Then determine if they are 'logged on' as say.. 15 minutes of time with no activity?

When you go to log on, query the database like

Code: Select all

$query = mysql_query("SELECT id FROM table WHERE username = '".$_POST['username']."' AND timelastactive >= '".time()-300."'");

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)st active on the site.  Perhaps on every page load, run a query to update this field.

Then determine if they are 'logged on' as say.. 15 minutes of time with no activity?

When you go to log on, query the database like

Code: Select all

$query = mysql_query("SELECT id FROM table WHERE username = '".$_POST['username']."' AND timelastactive >= '&quote;.time()-300.&quotetime a user was last active on the site.  Perhaps on every page load, run a query to update this field.

Then determine if they are 'logged on' as say.. 15 minutes of time with no activity?

When you go to log on, query the database like

Code: Select all

$query = mysql_query(&quote;SELECT id FROM table WHERE username = '&quote;.$_POSTї'username'].&quote;' AND timelastactive >= '&quote;.time()-300.&quote;'&quote;);

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
     die(&quote;User &quote;.$_POSTї'usrhaps on every page load, run a query to update this field.

Then determine if they are 'logged on' as say.. 15 minutes of time with no activity?

When you go to log on, query the database like

Code: Select all

$query = mysql_query("SELECT id FROM table WHERE username = '".$_POST['username']."' AND timelastactive >= '".time()-300."'");

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
     die(&quote;User ".$_POST['username']." is already logged i are 'logged on' as say.. 15 minutes of time with no activity?

When you go to log on, query the database like

Code: Select all

$query = mysql_query("SELECT id FROM table WHERE username = '".$_POST['username']."' AND timelastactive >= '".time()-300."'");

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
     die("User ".$_POST['username']." is already logged into the system.");
}
This is about e;.$_POST['username']."' AND timelastactive >= '".time()-300."'");

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
die(&quote;User &quote;.$_POSTї'username'].&quote; is already logged into the system.&quote;);
}

This is about the only way to do it since PHP is server side, and there's not a way to tell what the user is actually doing (client side).st active on the site. Perhaps on every page load, run a query to update this field.

Then determine if they are 'logged on' as say.. 15 minutes of time with no activity?

When you go to log on, query the database like

Code: Select all

$query = mysql_query("SELECT id FROM table WHERE username = '".$_POST['username']."' AND timelastactive >= '".time()-300."'");

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
     die("User ".$_POST['username']." is already logged into the system.");
}[/php:1:ba7f00user was last active on the site.  Perhaps on every page load, run a query to update this field.

Then determine if they are 'logged on' as say.. 15 minutes of time with no activity?

When you go to log on, query the database like

Code: Select all

$query = mysql_query("SELECT id FROM table WHERE username = '".$_POST['username']."' AND timelastactive >= '".time()-300."'");

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
     die("User ".$_POST['username']." is already logged into the system.");
}
This is about the only way to do it since PHP is server side, and there's not a way to tell what the user is actually doing (client side).
$query = mysql_query("SELECT id FROM table WHERE username = '".$_POST['username']."' AND timelastactive >= '".time()-300."'");

// this example is 5 minutes

// Check to see if the query was met
if(mysql_num_rows($query) > 0)
{
die("User ".$_POST['username']." is already logged into the system.");
}

This is about the only way to do it since PHP is server side, and there's not a way to tell what the user is actually doing (client side).

Posted: Fri Jul 15, 2005 5:20 am
by timvw
Here is my solution: http://timvw.madoka.be/programming/php/onlyone.txt
* This script makes sure a user can logged in only once at the same time.
*
* If the user requests a page, isValid should be called.
* This function compares the uid and cnt in the session with the uid and cnt in the database.
*
* If a user logs in, validate should be called.
* This function tests if the uid and pwd are valid, and if they are, the cnt is incremented.
*
* This way:
* If a user tries to login with a valid uid and pwd, he get's access. (No messing with session_timeout etc)
* If a user has logged in again, all the older sessions will have an invalid cnt.

Posted: Fri Jul 15, 2005 7:38 am
by fastfingertips
The problem is that if the second login is tried after 10 seconds the time stamp is useless. I think that is not important to limit a user to login in 10 broser windows, for you is important to allow just an user from a specific location to be logged using that details.

In this case you will have to check: time stamp and ip of the user. If the session is expired you should allow a user to login otherwise the user should wait untill time stamp expires. Ofc you will have some problems with the dial up users (if they reconnect they probably will have a different IP) but this cases are just a few.