Difference between #2 and #3 of
[Guide] How to actually separate Frontend (User) and Backend (Admin) on Yii2 Advanced

Revision #3 has been created by Wade Shuler on May 8, 2015, 3:42:51 AM with the memo:

clarity
« previous (#2) next (#4) »

Changes

Title unchanged

[Guide] How to actually separate Frontend (User) and Backend (Admin) on Yii2 Advanced

Category unchanged

How-tos

Yii version unchanged

Tags unchanged

yii2, user, auth, cookie, session, request, different, separate, backend, frontend, app, advanced, domain, login, autologin, CSRF, temp, cache, admin, user, member, system

Content changed

[...]
This was common sense for me. Since the backed didn't have it's own login form or model, I knew I needed to make an Admin model to use the 'admin' table in the database, and AdminLoginForm to use that Admin model (ie: Admin::findByUsername() ).

What wasn't clear, was what to do after that. There are issues with the cookies, session, and CSRF values. If we don't manually specify them in the config, then they try to use the same ones for both frontend and backend. That is why you see the weird behaviour, like being logged into both sides after logging into only one of them and getting an error when you try to logout. So let's setup the config.

To be honest, the Yii documentation is lacking, and skims over the advanced template.
Don't get me wrong, they wrote a lot and put a lot of effort into the docs that they do have. I just feel that the extra stuff isn't as greatly covered. Hopefully, it continues to grow and gives us more info on the extra stuff. Right now I feel I just have to Google what I need and hope someone else has already covered it.
 
 
These issues have nothing to do with programming knowledge, I have been programming for a long time and in many languages.. This has to do with just understanding Yii2. So don't get frustrated :)

In `frontend/config/main.php` you need to edit the 'user' component, and add 'session' and 'request' to the list.

####Truncated example of /frontend/config/main.php:####
[...]
9 1
18 followers
Viewed: 123 788 times
Version: 2.0
Category: How-tos
Written by: Wade Shuler
Last updated by: samdark
Created on: May 8, 2015
Last updated: 9 years ago
Update Article

Revisions

View all history