您的当前位置:首页>全部文章>文章详情

Thinkphp6 实现保持登录

发表于:2023-04-09 22:55:21浏览:765次TAG: #thinkphp

config/session.php

return [
    // session name
    'name'           => 'GITMKSESSID',
    // SESSION_ID的提交变量,解决flash上传跨域
    'var_session_id' => '',
    // 驱动方式 支持file cache
    'type'           => 'cache',
    // 存储连接标识 当type使用cache的时候有效
    'store'          => 'redis',
    // 过期时间
    'expire'         => 3*24*86400,
    // 前缀
    'prefix'         => '',
    'use_only_cookies'=>1,
    'use_trans_sid'=>1
];
return [
    // cookie 保存时间
    'expire'    => 3*24*86400,
    // cookie 保存路径
    'path'      => '/',
    // cookie 有效域名
    'domain'    => request()->host(),
    //  cookie 启用安全传输
    'secure'    => false,
    // httponly设置
    'httponly'  => true, //设置为 true
    // 是否使用 setcookie
    'setcookie' => true,
];