Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: already login

  1. #1
    New to the CF scene
    Join Date
    Feb 2004
    Thanked 0 Times in 0 Posts

    already login

    good day all.
    how php script (to know that someone already login with my username?)

  • #2
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Thanked 0 Times in 0 Posts
    As a single feature, this requires quite some overhead. So you can best do this if your complete sessionmanagement is also database-based. As outlined belowe.

    You create a table inside your database, where you insert a record each time a user logs in. You need to have a column in that table with the state of the session + another column with the PHP session ID + another colun with the userID. Initialy this is set to 'active'. When the client logs out, you set it to 'closed'. When the user requests a page, you check if there is a record with that sessionID + status=active. If so then update this record and set a timestamp or datetime field to Now().

    You create a cron-job (or scheduled task) that will run every 15 minutes and that updates all records to status='closed' if the last requested page is more then 15 minutes ago --> this will cause sessions to timout after maximum 29 minutes 59 seconds.

    When a user tryes to login, you run a select to see if there is already a record with that userID with status=active. Very simple check, but managing the sessiontable requires the real work here.
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html


    Posting Permissions

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