用户
 找回密码
 入住 CI 中国社区
搜索
查看: 1936|回复: 1
收起左侧

[Session/Cookie] CI3.0.4 redis存取session时session_id不断刷新

[复制链接]
发表于 2019-1-30 23:58:19 | 显示全部楼层 |阅读模式
本帖最后由 mchobby 于 2019-1-31 00:02 编辑

尝试移植一份比较老旧的源码到新的环境上。旧环境在apache + php5 + redis下,表现一切正常。
现在移植到 php 7.2 + nginx + redis 4.0.3 下,发现定制化的redis驱动(只实现了构造函数、open、read、write)得到的session_id一直在变,导致controller里写的$this->session->userdata()总是获取到空的内容。

我在定制驱动里写了log_message输出,看log是这样:
  1. ERROR - 2019-01-30 22:48:12 --> [Redis driver] successfully read tsk9hp41tpikb8r5lr7d1on1hs =
  2. ERROR - 2019-01-30 22:48:12 --> [Redis driver] successfully write tsk9hp41tpikb8r5lr7d1on1hs with content:
  3. ERROR - 2019-01-30 22:48:25 --> [Redis driver] successfully read gvdltgtnomvgs6tlr3jnm98osa =
  4. ERROR - 2019-01-30 22:48:25 --> [Redis driver] successfully write gvdltgtnomvgs6tlr3jnm98osa with content:
  5. ERROR - 2019-01-30 22:48:38 --> [Redis driver] successfully read keh9b77789f410slb329bjnaf3 =
  6. ERROR - 2019-01-30 22:48:38 --> [Redis driver] successfully write keh9b77789f410slb329bjnaf3 with content:
  7. ERROR - 2019-01-30 22:48:51 --> [Redis driver] successfully read krsg3h7iatnhqssamhvb5lqk4c =
  8. ERROR - 2019-01-30 22:48:51 --> [Redis driver] successfully write krsg3h7iatnhqssamhvb5lqk4c with content:
  9. ERROR - 2019-01-30 22:49:04 --> [Redis driver] successfully read h6f4tmnobpj0n46374dtc4il20 =
  10. ERROR - 2019-01-30 22:49:04 --> [Redis driver] successfully write h6f4tmnobpj0n46374dtc4il20 with content:
  11. ERROR - 2019-01-30 22:49:17 --> [Redis driver] successfully read n0fl5o0isq4cufc5773tsaasn6 =
  12. ERROR - 2019-01-30 22:49:17 --> [Redis driver] successfully write n0fl5o0isq4cufc5773tsaasn6 with content:

复制代码
项目源代码以及定制化的session_redis_driver驱动在这里:https://github.com/roastduck/fortuna-oj/blob/new-env/application/libraries/Session/drivers/MY_Session_redis_driver.php。

请问我应该往哪个方向去寻找问题?提前谢谢帮助!

 楼主| 发表于 2019-1-31 15:50:16 | 显示全部楼层
初步排除是redis驱动问题。
request header都能正确带上cookie中的session,但是服务器立刻下发了一个新的session……

本版积分规则