same login for different subdomain in YII2

1.7k views Asked by At

How to handle login in such case that, my frontend is on root of website i.e, http://www.example.com and backend in on subdomain http://admin.example.com. If i loggedin to root or in backend, it will automatically loggedin to other.

Goal: Login to both sites when logged in to one.

2

There are 2 answers

5
vamshi Krishna On

use session to store the id and use its data to login into other subdomain(s)

$session = new Session;$session->open();$value1 = $session['name1'];  // get session variable 'name1'

read about session here

1
Tony On

Try this method. I think this is what you looking for.