douyou4819 2016-06-20 09:05
浏览 39
已采纳

更改数据库服务器后,Yii会话停止工作

My server provider moved from datacenter. While moving something went wrong and the power supply to our dedicated database server failed. They setup a new virtual database as a backup plan so we can continue to keep going. I put back a backup of the data. After this however, Yii session do not seem to work anymore. Just to specify, only the database was effected. My code was just as it is and nothing changed there.

When I try something outside of the framework like:

session_start();
$_SESSION["test"] = 100;

That still works. It will store and I can use the session variable as you would expect. However when I use Yii code like Yii::app()->session["test"] = 100. I can not recall the data.

Extra information

  • Cookies do work. If they did not work. I would get a pop-up every time on page reload. So certain about this.
  • "sessionID in cookies is changed everytime on page reload" CORRECTION: Seems the id is not change in the cookies atm.
  • No session files are found on the server (I believe this might be the problem?)
  • The session file location is writeable (tested in PHP is_writable(Yii::app()->session->savePath) returns true)
  • YiiSession table is being update (cleared it and it does refill again)
  • Main.php config contains no component for session (so everything is on default)
  • I tried to set some session setting including the auto create database table. I deleted the table and it was automaticly created again.
  • YiiSession table contains id and expire
  • While the expire date seem rather short, it is still set well in the future
  • Went from a dedicated server to a temp virtual server (Both running centOs 6.6 + MySQL).
  • Session are stored on a virtual server that has been unaffected by the change.
  • Yii::app()->getSession()->getSessionId() returns a sessionId

Any suggestion what could be wrong? It seems rather odd this problems occures after a database server change.

BIG NOTE: Just noticed that in some setting file there is a component->session. It seems we use a custom HttpSession. I guess the problem might be in there. Will look trough it (see why the previous developer decide to create a custom class for this) and then use the default options and see if that fixes it.

  • 写回答

1条回答 默认 最新

  • dongxiang7276 2016-06-20 10:20
    关注

    It seems we where using a custom class. I disabled this and just added the setting

        'session' => array (
            'autoStart' => true,
        ),
    

    This seems to work for now. Will edit this answer if I find the specific in the custom class that caused this issue. The fact remains that this is wierd. I was not even aware of this custom class, let alone changed something in it.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog