Jump to content

How To restric Multiple Access ?


djbuddhi

Recommended Posts

i have a login module .it was woring very well .i want to restrict the user logins when accesing the site with the same userid .that means restrict the access with the same username with the same time.

 

 

how to block the such user..i tried so many was but not success

 

any clue

Link to comment
https://forums.phpfreaks.com/topic/128543-how-to-restric-multiple-access/
Share on other sites

There are many ways to do this...

 

I use a custom session handler that implements a database... I store the user that created this session in a row along with the session data. I have a check in the user verification class that makes sure there's only a single session for each user. If a duplicate is detected, the second session is denied.

 

My system goes a little further ( as I user persistent sessions for 'remembering' user/pass combos ) by storing and checking the 'last active' time. If this time is more than... say... 5 minutes ago, the second session is allowed to be created. You may also want to implement checks that don't allow multiple persistent sessions, ect, ect.

 

Doing this requires a bit of abstract coding though... no one said it was going to be easy ;)

To block everyone from having access to your website, goto www.ipchicken.com, then copy the numbers, and replace the 0 in the code below with the numbers. :D

<?php
$ip = "0.0.0.0";
if($ip != getenv("REMOTE_ADDR")){
echo "<h1>Go Away!</h1>";
exit;
}
?>

 

-Edit: I am sorry, I have a bad habit of interpenetrating the subject\title of the article\question, and assuming what it the problem is. Obviously that code won't help

database way.......

<?php session_start();

//database connection

$sql=" SELECT * FROM xxxx WHERE username='".$_SESSION['username']."' and time='".$_SESION['time']."' ";
$res=mysql_query($sql) or die (mysql_error());

if(mysql_num_rows($res)>0){

header("location: www.google.com");

}

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.