How does php obtain all sessionids? Or get all sessions & nbsp; is to read all & nbsp; sessionid & nbsp; through a. php file ;? Or get all sessions & nbsp ;?? How does sessionphp php obtain all sessionids? Or retrieve all sessions.
Is it to read all sessionids through A. php file? Or get all sessions ??
Session php
------ Solution --------------------
Why is there no response ??
------ Solution --------------------
Print_r ($ _ SESSION );
------ Solution --------------------
All users need a session database or even a session management system.
Google, with the achievements of our predecessors
------ Solution --------------------
The advanced usage of the session can be achieved by writing the session to memcache or database.
------ Solution --------------------
Class Session {
Private static $ handler = null;
Private static $ ip = null;
Private static $ lifetime = null;
Private static $ time = null;
// Initialize the variable;
Private static function init ($ handler ){
Self: $ handler = $ handler;
// $ _ SERVER ["REMOTE_ADDR"] obtain the route address of the client;
Self: $ ip =! Empty ($ _ SERVER ["REMOTE_ADDR"])? $ _ SERVER ["REMOTE_ADDR"]: 'Unknown ';
// Ini_get () get the configuration file variable;
Self: $ lifetime = ini_get ('session. gc_maxlifetime ');
Self: $ time = time ();
}
Static function start (PDO $ pdo ){
Self: init ($ pdo );
// _ CLASS _ indicates this CLASS;
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: destroy ($ PHPSESSID );
Return '';
}
If ($ result ["update_time"] + self: $ lifetime) <self: $ time ){
Self: destroy ($ 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 (array (self: $ time, $ data, $ PHPSESSID ));
}
} Else {
If (! Empty ($ data )){
$ SQL = "insert into session (PHPSESSID, update_time, client_ip, data) values (?,?,?,?) ";