PHP rewrite session mechanism code sharing code provided by Zhiyi blog
PHP rewrite session mechanism
Usage:
$ Session = new onmpwSessionHandler ($ config); session_set_save_handler ($ session, true );
$ Config is the configuration option.
$ Config = array ('SAVE _ handle' => 'redis', 'host' => '2017. 0.0.1 ', 'port' => 6379, 'auth' => null, // whether user verification exists. no password verification is performed by default. If it is not null, the verification password 'timeout' => 0, // connection TIMEOUT 'reserved' => null, 'retry _ interval' => 100, // The unit is MS millisecond 'reconnect '=> false, // whether the connection timed out is reconnected by default, not reconnected );
Example
Include 'onmpwsessionhandler. php '; $ session = new onmpwSessionHandler (array ('host' =>' 192. 168.5.111 ', 'port' => 6379); session_set_save_handler ($ session, true); session_start (); $ _ SESSION ['name'] = 'onmpw ';
For details about how to rewrite the session mechanism, refer to the article "rewrite the session mechanism in PHP ".