How to make two apps Yii1 and Yii2 use the same session?

I want to make a dashboard panel web in my existing website. The existing app is using Yii1. I want to make using new app using Yii2. I already made the apache configuration.

But what’s missing is the session. Users that logged in through Yii1 app will not be recognized in the dashboard.

How to make Yii1 and Yii2 use the same session data, i.e. user that logged in at Yii1 will be recognized in Yii2 vice versa?

The architecture is standard multiple web servers behind a load balancer. The two app can be hosted in the same server instance (the config will be in the apache). Or they can be in different (the load balancer will handle the directory too). But both will use the same memcache server for session storage.

Have you tried it already? Are you sure it doesn’t work?

It is possible to share session between two applications (Yii1 and Yii2). Here is how to do it if you are using CDbHttpSession in Yii1 and yii\web\DbSession in Yii2 (I didn’t test it with other types of session storage, but it should work same):

In Yii2 configuration for yii\web\DbSession for you application you should setup session name to be PHPSESSID so it can match one used by Yii1.

Since in Yii1 CWebUser use prefix for storing logged user id and other things from user state, you should set this to be empty string (or what ever you can share between both application. Yii2 doesn’t use prefix, so empty string works good too) ‘’. You can do it by extending CWebUser and add something like this inside public function init():

public function init() {




This is all what you need to be able to share session between two application.