Hello. Tell me how to make a conclusion on the screen of all authorized users at the moment (there was such a block on the ucoz service)? Or at least their count. I suppose you need to add a field like a state, a boolean type to the user table, write true during authorization, and false at the time of exit, then select the field and output either user names or count. At the moment, the authorization is done on the sessions, can you come up with something? I suggest to search for the last authorized user by the maximum id. Is it safe to use my method and will it work? Or maybe there is something simpler / more difficult, but more correct?

    2 answers 2

    1. Create a separate field to store datetime data.
    2. With each request from an authorized user, record the current time there.
    3. Do a sample of the database fields where the value of this parameter differs from the current one by no more than 10 (or as many minutes as you like).
    4. Is done.

    Request fragment for online users from the database: (now() - lastOnline) < " . время_в_секундах . " .

    According to id will not work, you just bring the newest user site, which is possible (or maybe not) is now online.

    Users do not leave profiles, for the most part, and when implemented as booleans, they will "hang" in the "who's online?" all the time.

      I suggest to search for the last authorized user by the maximum id

      Not in any way only by date and time.

      • And if not hard - do not tell me why? - abrgpro
      • @abrgpro, because the id field has a different semantics, and it does not have to monotonously grow - mymedia