List $_SESSION from different php users

Asked

Viewed 35 times

0

I searched a lot and nothing, there is the condition to list all users of different Sessions?

For example this script I use, lists only 1 user.

<?php

  include "db.php";


   $qryLista = mysqli_query($con, "SELECT C.*,L.xname,L.email  
    FROM       clientes C
    INNER JOIN usuarios L 
    ON         L.id=C.user_id 
    WHERE      C.user_id=".$_SESSION['id']." ");

    while($resultado = mysqli_fetch_assoc($qryLista)){
       $vetor[] = $resultado;
  }    

    echo json_encode($vetor, JSON_UNESCAPED_UNICODE ); 


?>

I intend to list all registered, it is possible?

1 answer

0

You will always return only the session that is running. I suggest for each of the logged users, a hash in the database, from time to time validate this hash, in this same function delete the hash with more than 5, 10 or 15 min without validation. Would be 2 columns plus HASH, DATETIMEVALIDATION In a MVC structure, you can place it in the constructors of each controller. Then you can know which are the active sessions searching in BD, all users with hash other than empty.

  • All right, I don’t know this technique hash in the database has a direct link that you can consult, because I did some research here and I was not successful, but emphasizes and clarifies about the concept hash, but, I would like an example.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.