From what I understand, you want to know if a another session, other than the user in question, does exist, right? If yes:
PHP stores session data in a temporary folder on the server, which you can find out what it is, or even define using session_save_path().
For each session, PHP creates a file sess_{SESSION_ID}
in that folder. You can get the list of files (sessions) using:
<?php
print_r(scandir(session_save_path()));
?>
If you want to know if a specific session exists, if you have SESION_ID, you can do the following:
<?php
session_start();
// $SESSION_ID = id da sessão que você quer saber se existe
echo (file_exists(session_save_path().'/sess_'.$SESSION_ID) ? "Existe!" : "Não existe!");
?>
As it seems that you want to search for the 'user', you would have to do the parse of those files and check for the information you need there. If you do not want to do the parse, you can take the ID of all sessions, which is in the file name and make a loop by initiating via session_start($SESSION_ID)
and searching for the data you need to check, in this case the user.
Remember that in no way this is a recommendation. There is still an option, which would be to manipulate the sessions yourself by setting a new one Handler. That way you could store the data in a database or any other way you prefer, but you need to make sure you know what you’re doing!
Finally, it seems that you just want to know if a user is online. There are other much safer and more efficient techniques to do this, but it is for a next question (or even should already have one about it).
But where will I inform the
id
from the session I want to check? I assigned $_SESSION['user'] the code "400379d4eaa6ec24826dd44cd5cf65a3".– Maicon Herverton
your question is not very clear, please edit it so I can help better
– alexandre9865
What don’t you understand? See: I have a session, where I assigned her several encrypted identifiers, and I want through one of these identifiers to know if the session is active or not, by the ID and not by the session itself!
– Maicon Herverton