Friday, June 21, 2013

Php Session ID, Session Save Path, Session List

ini_set('session.save_path', "C:\temp_sessions");
session_id(md5("".time())); /* every time set new session id */
//ini_set('session.gc_probability', 1); /* To remove previous sessions */
session_start();

echo session_id();
echo session_save_path();
echo "Session Save Path: " . ini_get( 'session.save_path');
$sessions = array();

$path = realpath(session_save_path());
$files = array_diff(scandir($path), array('.', '..'));

foreach ($files as $file)
{
    if(is_file($path.DS.$file) ) {
        $content = file_get_contents($path.DS.$file);
        $sessions[$file] = $path."/".$file;
        $sessions[$file."_content"] = unserialize($content);
    }
}

$path = session_save_path()."/*";

foreach (glob($path) as $file) {
    $diff = time() - filemtime($file);
    echo $file.", Last Updated= ".filemtime($file)."   ,Difference=   ".$diff."<br/>";
}

1 comment:


  1. Really awesome blog. Your blog is really useful for me. Thanks for sharing this informative blog. Keep update your blog.
    Hire Yii Developers in India

    ReplyDelete