Switch user from backend to frontend

Hi,

I need to switch user from backend to frontend. Something like that the super admin switches to another user.

I can switch user by Yii::$app->login(…) but it works only in backend or frontend. The problem is in session, because backend and frontend have different sessions.

Has anybody an idea, how to resolve this problem?

Thanks!

The advanced application is made up of two separate applications.

So, there is no possibility to do it?

You probably can - use a redirect and perform a login without user intervention.

If you are using REST then you can send a token and use auth to make it secure.

I haven’t tried it.

Just wanted to make you aware that we are essentially dealing with two separate Yii applications. That happen to use some common resources. :)

Two separate Yii applications which share code, mind you :rolleyes:

If you want to share sessions between the backend and frontend, you can do so. First thing would be configuring the session cookie so it wasn’t locked down to a single hostname, and then you would have to build an auth piece around it. Not too difficult I suppose.

Or like mentioned you have the option of kicking them to a URL which logs them in to the backend automatically. For instance, generate a unique, one-time log in hash. Lock it down to user agent, IP (depending on requirements), user id, etc. etc. and keep it valid for a short period of time (15 seconds?). Match that user hash to a user ID, log them in, invalidate the hash.