I need to check if each session over my website is still active or not.
I used to cycle over each session in the folder given by the php command session_save_path()
, the problem is that even if a session expires, the respective folder doesn't modify at all.
How can I solve this? I have PHP 5.3, otherwise I would have tried something like session_status()
, which I think can solve my problem.
Here's my code:
$sessionNames = scandir(session_save_path());
foreach($sessionNames as $sessionName) {
$sessionName = str_replace("sess_","",$sessionName);
if(strpos($sessionName,".") === false) { //This skips temp files that aren't sessions
session_id($sessionName);
session_start();
// CHECK IF THE SESSION IS ACTIVE OR EXPIRED
session_write_close();
}
}
Thank you!