How does PHP get all the SessionID? Or get all the session
Just want to read all the SessionID through a. php file? Or get all the session??
Session PHP
------Solution--------------------
Why is no one back??
------Solution--------------------
Print_r ($_session);
------Solution--------------------
All users need session database or even a session management system.
Google, have the results of previous efforts
------Solution--------------------
Advanced usage of the session, write the session to the Memcache or database, you can achieve
------Solution--------------------
Class Session {
private static $handler =null;
private static $ip =null;
private static $lifetime =null;
private static $time =null;
Initialize variables;
private static function init ($handler) {
Self:: $handler = $handler;
$_server["REMOTE_ADDR"] Gets the client routing address;
Self:: $ip =!empty ($_server["REMOTE_ADDR"])? $_server["REMOTE_ADDR"]: ' Unknown ';
Ini_get () Gets the configuration file variable;
Self:: $lifetime =ini_get (' session.gc_maxlifetime ');
Self:: $time =time ();
}
static function Start (PDO $pdo) {
Self::init ($PDO);
_class_ represents this category;
Session_set_save_handler (
Array (__class__, "open"),
Array (__class__, "close"),
Array (__class__, "read"),
Array (__class__, "write"),
Array (__class__, "destroy"),
Array (__class__, "GC")
);
Session_Start ();
}
public static function open ($path, $name) {
return true;
}
public static function close () {
return true;
}
public static function read ($PHPSESSID) {
$sql = "Select Phpsessid, Update_time, CLIENT_IP, data from session where phpsessid=?";
$stmt =self:: $handler->prepare ($sql);
$stmt->execute (Array ($PHPSESSID));
if (! $result = $stmt->fetch (PDO::FETCH_ASSOC)) {
Return ';
}
if (self:: $ip! = $result ["Client_ip"]) {
Self::d Estroy ($PHPSESSID);
Return ';
}
if ($result ["update_time"] + self:: $lifetime) < self:: $time) {
Self::d Estroy ($PHPSESSID);
Return ';
}
return $result [' data '];
}
public static function Write ($PHPSESSID, $data) {
$sql = "Select Phpsessid, Update_time, CLIENT_IP, data from session where phpsessid=?";
$stmt =self:: $handler->prepare ($sql);
$stmt->execute (Array ($PHPSESSID));
if ($result = $stmt->fetch (PDO::FETCH_ASSOC)) {
if ($result [' data ']! = $data
------Solution--------------------
Self:: $time > ($result [' Update_time ']+30)} {
$sql = "Update session set Update_time =?, data =?" where PHPSESSID =? ";
$stm =self:: $handler->prepare ($sql);
$stm->execute (self:: $time, $data, $PHPSESSID));
}
}else{
if (!empty ($data)) {
$sql = "INSERT into session (PHPSESSID, Update_time, CLIENT_IP, data) VALUES (?,?,?,?)";