/    Sign up×
Community /Pin to ProfileBookmark

how to allow only one user to connect my site. using same username and password!

one username and password is given to a group of 5 users … but only allow one to connect mysite each time … currently i am using session to store the username and password … i wonder how to permit only one user using same username and password to connect to the page … is it possible to detect the session, if the session isn’t closed or destroyed then someone using the same username and password are not allowed to connect? only after the previous user who using the username and password has logged out, and the session is closed and destroyed, then he is allowed to connect … cos i don’t want to let multi-users online at the same time using the same username and password … any idea how?

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@NevermoreMay 19.2004 — You would have to write to a file every time someone logs in or views a page, marking the time. Then if someone either logs out or is idle for 15 minutes someone else is able to log in instead.
Copy linkTweet thisAlerts:
@ltingauthorMay 19.2004 — emm how am i going to check whether they are using the same username or not? if someone login using the username and then another person is not allow to login using the same username again .. he/she have to wait till the previous user log out, then only he/she is allowed to use that username to login ... users with same username only can allow one to login to my page each time .. they can't login together using the same username ...
Copy linkTweet thisAlerts:
@NevermoreMay 19.2004 — You only have to prevent the log in. Once one person is logged in, prevent further logins.
Copy linkTweet thisAlerts:
@ltingauthorMay 21.2004 — emm then how i write the data into a file ... and how i retrieve the data inside the file to check whether one person is log in at that moment .. besides .. if the person didn't log out the website .. but he close the browser directly ... then how i ensure the person is already log out?
Copy linkTweet thisAlerts:
@NedalsMay 21.2004 — Here's a scheme that could work... (I'm guessing that you have nothing at the moment)

This will use a session cookie to keep track of a 'logged in' user.

LOGIN =>

// A logged-in user accessed the 'user_page' within the last 15 mins (or whatever)

if ((tflag + 15mins > current_time) {

login NOT allowed

}

// user_page has not been accessed for 15 mins, so allow this user

else {

set tflag = current_time

set random_code (different for each login)

set a cookie (where cookie = random code)

return the 'user_page'

}


LOGOUT =>

Clear tflag

// If user does not logout, the tflag setting will allow another user after 15 mins


USER tries to accesses page

if (no cookie) {

message - 'You are not authorized.....'

else if (cookie == random_code) {

tflag = current_time (updating)

return 'user_page'

}

else {

message - 'Your session has timed out....'

}

Hope that makes sense ?
Copy linkTweet thisAlerts:
@jcy110Jan 07.2011 — I would like to try this, what additional pages have to be made on my website?

Where is the code you are showing put? On what page? or is it a script that resides on a page in the cgi-bin?

Where does the page with the usernames and passwords reside?

Any help would be appreciated.
×

Success!

Help @lting spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...