Home >Backend Development >PHP Tutorial >PHP重写session机制代码分享

PHP重写session机制代码分享

WBOY
WBOYOriginal
2016-06-23 13:05:091029browse

代码由 迹忆博客提供

PHP重写session机制

使用方法:

$session = new onmpwSessionHandler($config);session_set_save_handler($session,true);

其中参数$config是配置选项

$config = array(    'SAVE_HANDLE'=>'Redis',    'HOST'=>'127.0.0.1',    'PORT'=>6379,    'AUTH'=>null,    //是否有用户验证,默认无密码验证。如果不是为null,则为验证密码    'TIMEOUT'=>0,   //连接超时    'RESERVED'=>null,    'RETRY_INTERVAL'=>100,  //单位是 ms 毫秒    'RECONNECT'=>false, //连接超时是否重连 默认不重连);

使用示例如下

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';

关于如何重写对session机制进行重写,可以参考 《PHP重写session机制》这篇文章

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn