Current location: Hot Scripts Forums » Programming Languages » PHP » Preventing multiple logins


Preventing multiple logins

Reply
  #1 (permalink)  
Old 06-19-04, 04:07 PM
bob23 bob23 is offline
New Member
 
Join Date: Jun 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Preventing multiple logins

I hope you can help me solve a tricky problem. I have a basic login script that i use to secure a website for members only. To solve the problem of individuals sharing password to access the service i am trying to come up with a php (perhaps using mysql too) script to prevent other individuals accessing the service from another computer if the account is already being used by another user ie. one user logged in at a time with an individual username and password

I hope you can all help, as i am now tearing my hair out

regards

bob
Reply With Quote
  #2 (permalink)  
Old 06-20-04, 12:57 AM
<?Wille?> <?Wille?> is offline
Junior Code Guru
 
Join Date: Jan 2004
Location: Helsinki, Finland
Posts: 666
Thanks: 0
Thanked 0 Times in 0 Posts
sounds prittey trickey.. you could make a new column to your users table that updates to ex 2 when they log in and to 1 when log out.. a online/offline checker. and then check users status in login
something like:
PHP Code:

$dbPwd // form db

$pwd $_POST['pwd']; // from login form
$UserStatus //from db

if ($dbPwd == $pwd && $UserStatus == 1) {
     
// go to protected page
} else {
     
// user is already online 
storeing last login date and time would probably also be a good thing.. this one works AS LONG as your members click the logout link when they are finished.. if they close the browser or leave the site without logging out that username will not be accessable becourse it will say users already online.. so i would say you think about some kind of date time thing.. if they are online but last login was 2days ago.. then let users pass or something..

hope i helped
Wille
Reply With Quote
  #3 (permalink)  
Old 04-28-09, 10:26 PM
satay satay is offline
New Member
 
Join Date: Apr 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
hello
But how we update the user status at the time of logout.Please tell me.
Reply With Quote
  #4 (permalink)  
Old 04-29-09, 10:55 PM
Jcbones Jcbones is offline
Aspiring Coder
 
Join Date: Mar 2009
Location: North Carolina, USA
Posts: 516
Thanks: 5
Thanked 47 Times in 44 Posts
I would assume that you could just use an UPDATE query.

PHP Code:

if($_GET['cmd'] == 'logout')
   {
     
$query "UPDATE `user` SET `userStatus`='0' WHERE `id`='$userID'";
          if(
mysql_query($query)) echo 'You have been logged out!';
   } 
Reply With Quote
  #5 (permalink)  
Old 04-30-09, 10:33 PM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,515
Thanks: 20
Thanked 109 Times in 106 Posts
Don't forget that many users never log out - they just close their browser or shutdown the computer.

You would need a cron job to indicate that a user has logged out after the session times out.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
transfer multiple value of a form field to another field ore JavaScript 2 06-18-04 08:50 PM
multiple folders and pages (please help) ogames PHP 3 05-21-04 05:03 PM
Sending multiple mails thru outlook loony_1313 Windows .NET Programming 0 04-17-04 03:01 PM
Putting multiple values from list into one field rush989 PHP 1 02-04-04 04:47 AM
multiple class="mainFormBox" - MYSQL dihan PHP 0 01-12-04 03:45 PM


All times are GMT -5. The time now is 05:03 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.