天天看点

php TP5.1 将session 存入Redis

php TP5.1 将session 存入Redis

只需要更新​

​session.php​

​配置文件即可;

<?php

// +----------------------------------------------------------------------
// | 会话设置
// +----------------------------------------------------------------------
return [
    'id' => '',
    // SESSION_ID的提交变量,解决flash上传跨域
    'var_session_id' => '',
    // SESSION 前缀
    'prefix' => 'think',
    // 驱动方式 支持redis memcache memcached
    'type' => 'redis',
    'auto_start' => true,// 是否自动开启 SESSION
    'httponly' => true,// httponly设置
    'timeout'      => 0, // 超时时间(秒)
    'persistent'   => true, // 是否长连接

    'session_name' => 'session_stu_', // sessionkey前缀
    'host'    =>    Env::get('config_cache.hostname'),// redis主机
    'port'=>  Env::get('config_cache.port'),// redis端口
    'select'=>  Env::get('config_cache.select'),// 选择第几个Redis库
    'expire'       => 3600, // 有效期(秒)
    'password' => Env::get('config_cache.password'),// 密码
];      

注意:TP6.0

需要更新​

​cache.php​

​​和​

​session.php​

​两个配置文件;

你要保守你心,胜过保守一切。