How to change user session after user login using CakePHP?
I have
$user = $this->Auth->user();
which fetches the current user from the session.
I want the admin user to be able to "act like" the client. And I was hoping I could just replace the customer_id in the user session when they enter the UI.
$user['User']['customer_id'] = 4;
It doesn't work because I can't find a way to return user $ data in Auth
+1
a source to share
3 answers
Try to combine $this->Auth->logout()
and then $this->Auth->login()
with customer data.
However, you need to implement additional logic if you want your administrator to be able to return to their account without entering their credentials again. This is not a problem, but worth mentioning.
0
a source to share