PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, March 8, 2022

[FIXED] Yii sessions stopped working after changing database server

 March 08, 2022     php, session, yii     No comments   

Issue

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.


Solution

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.



Answered By - Jeroen
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing