$request->sessionId()刷新页面就会变化

moco

问题描述

获取请求sessionId
$request->sessionId(); 刷新页面就会发生变化,同一个浏览器同一个页面刷新就变。这个是配置问题吗?

<?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\Session\FileSessionHandler;
use Webman\Session\RedisSessionHandler;
use Webman\Session\RedisClusterSessionHandler;

return [

    'type' => 'redis', // or redis or redis_cluster

    'handler' => RedisSessionHandler::class,

    'config' => [
        'file' => [
            'save_path' => runtime_path() . '/sessions',
        ],
        'redis' => [
            'host' => getenv('REDIS_HOST'),
            'port' => 6379,
            'auth' => getenv('REDIS_PASSWORD'),
            'timeout' => 2,
            'database' => 5,
            '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',

    'auto_update_timestamp' => false,

    'lifetime' => 7*24*60*60,

    'cookie_lifetime' => 365*24*60*60,

    'cookie_path' => '/',

    'domain' => '',

    'http_only' => true,

    'secure' => false,

    'same_site' => 'none',

    'gc_probability' => [1, 1000],

];
231 7 0
7个回答

six

配置问题

  • moco 9天前

    大佬 应该怎么配置呀。能给个例子吗

发下session配置,以及是否使用了https访问

  • moco 8天前

    老大 session配置发出来了 没有使用https访问 用的是http

  • walkor 8天前

    'type' => 'redis', 改成 'type' => 'file', 试下。
    另外webman前面是否用了代理,例如nginx等

  • moco 8天前

    使用file 也是一样的 每次请求都会变化 没有使用代理 直接就是ip加端口号

  • walkor 8天前

    创建一个空的新的webman项目,session配置保持不动试下,如果没问题,自己对比下项目哪里不一样

nitron

看配置好像你的handler对应的SessionHandler写错了,你用FileSessionHandler去处理RedisSession,用前朝的剑斩本朝的官

  • moco 8天前

    我来修改下看看

  • moco 8天前

    修改之后 还是每次请求 都会变化

  • nitron 8天前

    再提供下类似操作系统,PHP版本,composer包等信息吧,方便排查,光看配置看不出啥东西

  • moco 8天前

    Ubuntu 20.04 64位 Composer version 2.8.7 php8.2

咸鱼.php

这个21年遇见过一次,当时还是tp的项目,卸掉apache换nginx后正常,至今不清楚为什么,仅供参考。

  • 暂无评论
morris

你是不是http访问的。 chrome 安全原因 。 咋 http协议 不能写cookie 。 httponly 啥的

  • 暂无评论
ichynul

遇到过类似问题,response和其他对象循环引用,导致session的__destruct不触发,没保存下来。

  • 暂无评论
🔝