1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

users logged in script

Discussion in 'PHP' started by jquilno, Aug 9, 2006.

  1. #1
    i have a startup website, BigRedNumber.com, and i use php with a mysql backend to store information.

    my question is, how can i create a "users logged in now" script? i want to have the "users logged in now" part of the site dynamic, instead of having to purge the user login cache (login information is stored as a 1 or 0 in user database)?

    right now, when a user logs in, the login field on his database entry becomes 1, but if he doesnt log out by clicking "logout" (i.e. he closes the browser window) he remains "logged in." i only want to show people who are logged in (and clicking) at the time the page is loaded.

    thnx
    j.
     
    jquilno, Aug 9, 2006 IP
  2. webviz

    webviz Peon

    Messages:
    216
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    <?php

    // ... init classes and whatnot...

    if($user->logged != true)
    {
    $display->tpl('login_you_idiot');
    }

    // ... once the idiot logs in..

    $db->query("UPDATE `status` SET `logged` = '1' WHERE `id = '{$user->id}'");

    // where did $user->id come from? once the user logged in set the new values

    // ...

    ?>






    What you are asking for requires a full working member system thing
     
    webviz, Aug 9, 2006 IP
  3. casper

    casper Guest

    Messages:
    181
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I would set a date/time combination in my DB rather than adding a 'logged in boolean' like webviz suggested.

    If the user would log on a boolean login system but would not log out properly, the user could be 'active' forever, unless the system would actively scan the userlist, which is a waste of resources.

    When setting a date, you could use a simple query like;

    And when you have stored a date/time combination in your db you can also add a welcome message like;

     
    casper, Aug 10, 2006 IP