Yii 会话在多服务器中不起作用 [英] Yii session do not work in multi server

查看:45
本文介绍了Yii 会话在多服务器中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 1 台负载平衡服务器和 2 台 Web 服务器:Server1 和 Server2.它们都与 DB Server 连接.我的问题:我正在使用 Yii 会话来控制会话.在我登录到 Server1 成功后,负载均衡服务器重定向到 Server 2=> 它不保留我之前登录的会话 (server1)

I have 1 load balancing server and 2 web servers: Server1 and Server2. Both of them connect with DB Server. My problem: I am using Yii session to control session. After I login success into Server1, loadbalancing server redirect to Server 2 => It's doesn't keep session that I login before (server1)

如何在 Server2 中保持会话

What can I do to keep session in Server2

推荐答案

除了 Charles 的评论之外,还有一些其他想法.

A few other thoughts in addition to Charles' comments.

1) 您可以使用 CDbHttpSession 而不是单独设置 memcached 服务器.这会将您的会话存储在您的网络服务器后面的数据库服务器中.

1) You can use CDbHttpSession instead of getting a memcached server setup separately. This will store your session in your DB server behind your web servers.

2) 您是否为您的服务器启用了 Suhosin?如果这样做,将会引起许多的麻烦,因为 Suhosin 会加密您的会话变量(并且会在每个服务器上以不同的方式进行加密),从而导致您的会话无法在服务器之间共享.

2) Do you have Suhosin enabled for your servers? If you do, it will cause many headaches, as Suhosin encrypts your session variables (and will do it differently on each server), causing your sessions to not be shared between servers.

祝你好运,如果你有更多问题,请回来.在解决错误的过程中,我们花了一些时间转向负载平衡器.

Good luck and come back with more questions if you have them. Shifting to a load balancer took us a while as we worked through the bugs.

这篇关于Yii 会话在多服务器中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆