您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
webman-session管理-配置文件-更換session驅動為redis
发布时间:2022-01-27 21:00:31编辑:雪饮阅读()
更換session存儲驅動,其默認驅動是file驅動。若要修改需要修改config/session.php:
/**
* This file is part of webman.
*
* Licensed under The MIT License
* For full copyright and license information, please see the MIT-LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @author walkor<walkor@workerman.net>
* @copyright walkor<walkor@workerman.net>
* @link http://www.workerman.net/
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
use Webman\FileSessionHandler;
return [
//'type' => 'file', // or redis or redis_cluster
'type'=>'redis',
'handler' => Webman\FileSessionHandler::class,
'handler' => Webman\RedisSessionHandler::class,
'config' => [
'file' => [
'save_path' => runtime_path() . '/sessions',
],
'redis' => [
'host' => '127.0.0.1',
'port' => 6379,
'auth' => '',
'timeout' => 2,
'database' => '',
'prefix' => 'redis_session_',
],
'redis_cluster' => [
'host' => ['127.0.0.1:7000', '127.0.0.1:7001', '127.0.0.1:7001'],
'timeout' => 2,
'auth' => '',
'prefix' => 'redis_session_',
]
],
'session_name' => 'PHPSID',
];
然後redis服務端運行:
{
// 给session赋值
session(['key1'=>'value1', 'key2' => 'value2']);
// 相当于
session()->put(['key3'=>'value3', 'key4' => 'value4']);
// 相当于
$request->session()->put(['key5'=>'value5', 'key6' => 'value6']);
$allSession=session()->all();
return response(var_export($allSession,true));
}
关键字词:webman,session,管理,配置,文件,-更換,驅動,為,redis
相关文章
- webman-session管理-助手函数session()-給session賦值
- webman-session管理-助手函数session()-獲取某個值
- webman-session管理-助手函数session()-session實例獲
- webman-session管理-判断对应session数据是否存在
- webman-session管理-删除所有session数据
- webman-session管理-删除session数据
- webman-session管理-存儲session(set與put)
- webman-session管理-獲取session中某個值
- webman-session管理-獲取所有session
- webman-session管理-例子