djbuddhi Posted October 15, 2008 Share Posted October 15, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/128543-how-to-restric-multiple-access/ Share on other sites More sharing options...
Maq Posted October 15, 2008 Share Posted October 15, 2008 So what's the problem? Can we see your code? We need a little more information cause right now all I can say is that you need a query to check to see if that user_name is logged in. You could even use sessions. Quote Link to comment https://forums.phpfreaks.com/topic/128543-how-to-restric-multiple-access/#findComment-666172 Share on other sites More sharing options...
discomatt Posted October 15, 2008 Share Posted October 15, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/128543-how-to-restric-multiple-access/#findComment-666180 Share on other sites More sharing options...
djbuddhi Posted October 16, 2008 Author Share Posted October 16, 2008 can i have a sample code of what u have saying ... Quote Link to comment https://forums.phpfreaks.com/topic/128543-how-to-restric-multiple-access/#findComment-666738 Share on other sites More sharing options...
Lamez Posted October 16, 2008 Share Posted October 16, 2008 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. <?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 Quote Link to comment https://forums.phpfreaks.com/topic/128543-how-to-restric-multiple-access/#findComment-666748 Share on other sites More sharing options...
redarrow Posted October 16, 2008 Share Posted October 16, 2008 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"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/128543-how-to-restric-multiple-access/#findComment-666808 Share on other sites More sharing options...
djbuddhi Posted October 16, 2008 Author Share Posted October 16, 2008 Is this query will be fail if we used session['time'] ? isn't it ? Quote Link to comment https://forums.phpfreaks.com/topic/128543-how-to-restric-multiple-access/#findComment-666841 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.