954,585 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

source code for blocking parallel logins using PHP

hi friends,


How To Block Parallel Login?
How to block parallel login? How can I block multiple login attempts in to a single account, when that user have already logged in? Like... Yahoo/Hotmail email accounts...

1. When I logged in, using & from
2. Until I logout or close my browser, the system should not allow me to login again from or from any other pc, using same and .

How can I solve my problem?

akash_msrit
Light Poster
30 posts since May 2007
Reputation Points: 10
Solved Threads: 0
 
hi friends, How To Block Parallel Login?

You can keep a list of who is logged in,
or you can use a cookie.

A session variable won't do it because each
session would have its own value.

ingeva
Junior Poster
106 posts since Jul 2008
Reputation Points: 16
Solved Threads: 9
 

You can keep a list of who is logged in, or you can use a cookie.

A session variable won't do it because each session would have its own value.

Cookie will not help at all because a second login attempt may come from a different browser.

You just need a database table where you keep the data about logged-in users like username, login_time, browser, ip_address

You can always check against this table before you let a user to login.

Some issues have to be worked out like what if user logged in but then closed his browser. His login details will still be stored in the database while technically he is no longer logged in.

So if a user has not logged out using a logout link, it's hard to know if the user is still on your site or not.

uncle_smith
Light Poster
49 posts since Jan 2009
Reputation Points: 18
Solved Threads: 7
 

hi,

can you give me sample code or an example


Best Regards
akash

akash_msrit
Light Poster
30 posts since May 2007
Reputation Points: 10
Solved Threads: 0
 

hi,

can you give me sample code or an example

Best Regards akash

try this http://sourceforge.net/projects/phploginsystemw/

rm_daniweb
Junior Poster
165 posts since Jan 2007
Reputation Points: 13
Solved Threads: 12
 

hi,

thanks for the url, i didn't got any information in that site.

i can implement that in this way:


create a database for users.

when user logs in i will make an entry in my table.
when user logs out i will delete that entry.

the problem is when user closes the site using Alt + f4 or close group. the entry in table remains. and user can't login again.

any suggestion for this. or sample code which does this task.

Regards
akash

akash_msrit
Light Poster
30 posts since May 2007
Reputation Points: 10
Solved Threads: 0
 

see the table structure of the link that I gave to you.

rm_daniweb
Junior Poster
165 posts since Jan 2007
Reputation Points: 13
Solved Threads: 12
 

There is a way to deal with client closing a browser or just leaving the site. Use javascript and define onUnload() that would call your script via Ajax to notify your server that client is leaving, so your script can update the session table and mark that client as logged-out.

uncle_smith
Light Poster
49 posts since Jan 2009
Reputation Points: 18
Solved Threads: 7
 

Call logout.php
I am assuming that you have written code for deletion in logout.php

define onUnload()
{
window.location ='logout.php';
}
urtrivedi
Nearly a Posting Virtuoso
1,306 posts since Dec 2008
Reputation Points: 257
Solved Threads: 270
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You