I have 2 auth area's in my website. - domain/admin (admin area) - domain/clients (clients area)
Admin has a different model and clients has a different model.
I am using $this->Auth(); I use the following code to identify If the user is authorized.
public function isAuthorized($user) {
// Client ACL
if ($this->params['controller'] == 'clients'):
if (isset($user) && !empty($user['business_type'])) {
return true;
} else {
return false;
}
endif;
}
This works fine. The problem is, when I login to admin area and go to client area URL, It shows as I am logged in. I want to have 2 different sessions for admin area and client area.
How do I identify If a user is actually logged into admin area or client area. And I want to develop a mechanism in which an admin and client can login at the same time from same browser.
I am also using admin prefix for admin area, which is why isAthorized code for admin area is stored in AppController.php
You have to use AuthComponent::$sessionKey http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#AuthComponent ::$sessionKey
Since you are using admin prefix, you can set a $sessionKey for admin area in AppController.php.
Example:
AuthComponent::$sessionKey = 'Auth.Admin';
And in your client's controller you can create another session key for clients.
AuthComponent::$sessionKey = 'Auth.Client';
This will resolve the issue.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.