Jump to content

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");

}

?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.