Created
December 16, 2017 15:46
-
-
Save johnss/27702ffc749d9fa2accdace862609259 to your computer and use it in GitHub Desktop.
Online counter using session_save_path()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
define("MAX_IDLE_TIME", 3); | |
class online{ | |
function who(){ | |
$path = session_save_path(); | |
if (trim($path)=="") { | |
return FALSE; | |
} | |
$d = dir( $path); $i = 0; | |
while (false !== ($entry = $d->read())) { | |
if ($entry!="." and $entry!="..") { | |
if (time()- filemtime($path."/$entry") < MAX_IDLE_TIME * 60) { | |
$i++; | |
} | |
} | |
} | |
$d->close(); | |
return $i; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment