Difference between #6 and #7 of
Configuring different sessions for backend and frontend in Yii advanced app

Revision #7 has been created by Kartik V on Sep 6, 2015, 6:04:59 AM with the memo:

Add session parameters
« previous (#6)

Changes

Title unchanged

Configuring different sessions for backend and frontend in Yii advanced app

Category unchanged

How-tos

Yii version unchanged

Tags unchanged

yii2, user, auth, cookie, session, different, backend, frontend, app, advanced, domain, login, autologin

Content changed

[...]
]
```

However, if you require cookies for ideal user experience, you need to follow the approach below.

### Option 2: Configure Identity Cookie
 & Session You can configure different identity cookies and sessions for your user component for frontend and backend app. Note the unique **name** property in **identityCookie**.

#### Backend Config
[...]
// in backend/config/main.php
'user' => [
  'identityClass' => 'app\models\User',    'enableAutoLogin' => true,   'identityCookie' => [   'name' => '_backendUser', // unique for backend   'path'=>'/advanced/backend/web' // correct path for the backend app.   ]]
 
],
 
'session' => [
 
    'name' => '_backendSessionId', // unique for backend
  'savePath' => __DIR__ . '/../runtime', // a temporary folder on backend
 
],
```
[...]
// in frontend/config/main.php
'user' => [
  'identityClass' => 'app\models\User',    'enableAutoLogin' => true,   'identityCookie' => [    'name' => '_frontendUser', // unique for frontend   'path'=>'/advanced/frontend/web' // correct path for the frontend app.   ]
 
  
]
 
],
 
'session' => [
 
    'name' => '_frontendSessionId', // unique for frontend
 
    'savePath' => __DIR__ . '/../runtime', // a temporary folder on frontend
 
], ``` This should now allow you to have cookie based login, but different authentication sessions for frontend and backend.
4 0
46 followers
Viewed: 48 470 times
Version: 2.0
Category: How-tos
Written by: Kartik V
Last updated by: Kartik V
Created on: May 17, 2014
Last updated: 8 years ago
Update Article

Revisions

View all history