Use Single Login Session on All Your Yii2 Application/Repository Under Same Domain/Sub Domain

Comparing #1 with #2

Revision #2 was created by aayushmhu aayushmhu on Sep 10, 2024, 12:24:36 PM.

article

Tags

session,login,single-login

Content


 
There are multiple blog that shows how to use seperate login for yii2 application but in this article i will show you how to use a single login screen for all your YII2 Advanced, YII2 Basic, Application, It will also work when your domain on diffrent server or the same server.

Here are few Steps you need to follow ot achive this.
[...]
Step 1 : Add this into your component inside

 
/path/common/config/main.php
 
```php
'components' => [
'user' => [
[...]
```


 
Step 2: Add Session and Request into main-local.php
 
/path/common/config/main-local.php
 
 
```php
'components' => [
'session' => [
[...]
/path/frontend/config/main-local.php

 
/path/backend/config/main-local.php
 
```php
'components' => [
'request' => [
[...]
Step 4: Note Somethign that you also have and console application so update session, user,and request into the main-local.php of your console application


 
/path/console/config/main-local.php
 
 
```php
'components' => [
'session' => null,
[...]
Step 1: Update You main-local.php of basic template


 
/path/basic-app/config/main-local.php
 
 
```php

'components' => [
'session' => [
'cookieParams' => [
'path' => '/',
[...]