www.webdeveloper.com
Results 1 to 7 of 7

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

  1. #1
    Join Date
    Dec 2003
    Location
    Malaysia
    Posts
    206

    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?

  2. #2
    Join Date
    Feb 2003
    Location
    Britain
    Posts
    1,335
    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.

  3. #3
    Join Date
    Dec 2003
    Location
    Malaysia
    Posts
    206
    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 ...

  4. #4
    Join Date
    Feb 2003
    Location
    Britain
    Posts
    1,335
    You only have to prevent the log in. Once one person is logged in, prevent further logins.

  5. #5
    Join Date
    Dec 2003
    Location
    Malaysia
    Posts
    206
    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?

  6. #6
    Join Date
    Dec 2002
    Location
    Pleasanton, CA
    Posts
    2,132
    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

  7. #7
    Join Date
    Jan 2011
    Posts
    1

    one unique username/password login at a time

    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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles