Unexpected Session Switching happening randomly in Yii 2.0

Dear Sir / Madam

We have a peculiar situation happening over a period of few weeks, wherein, Session of any logged in user, is being automatically changed to another user, due to which, all business activity in the application, are happening with the other user, for the subject (whose session is changed / automatically hijacked).

Note: The Session is being "Changed To", Session of Users who had enabled Permanent Cookie using "Remember Me" checkbox, as per our initial observations. Most of the time, this random session override is happening automatically to a single user account, for all users (whose session is being overridden)

We are using Yii 2.0 for all our applications and this problem is imminent and the root cause is still not established, for sure.

We do really appreciate, inputs in this regard

thank you


Where sessions are stored? Is there any cache involved? How identity is implemented? How is it stored? Any load balancing involved? Multiple servers?

Hi Samdark

We are using CPanel/WHM managed linux servers to host our web application.

  1. About Session Storage:

By default, we are using file based session storage, and the sessions are stored in /tmp folder (that is outside public_html, i.e., /home/cpanel_username/tmp).

With the recent CPanel / WHM update, we had enabled session storage for all websites, in CPanel’s internal session storage path.

Since this current problem is persisting in both scenarios, we had moved sessions to, our custom chosen Session Save path (i.e., /home/cpanelusername/sessions).

Still the problem persisted…

  1. About Cache as Session Store:

Currently, we are not using any in-memory cache (memcache / redis etc), to store sessions

  1. About Yii based User Identity implementation:

We are using Dektrium Yii2 User Extension, to handle User management.

  1. About User Data Storage:

We are using MySQL database to store user information

  1. About Load Balancer usage and Multiple Server scenario:

Currently, this is based on a single virtual server, wherein, both web server and database server exists. We are Apache as HTTP Server and MySQL as Database Server and using Nginx as reverse proxy in this setup.

Finally, I would like to add that, we had enabled HTTPS before few months.

please share your inputs

thank you


Sounds like caching in either nginx or Apache.

Its working after removing ngnix as reverse proxy before apache.Thank you!!