Sankalp Sankalp - 10 months ago 38
PHP Question

Auth Component's user function not working in case multiple routing

I have routed my site as admin moderator. Means When I use Auth component my sessions are created as

this way.

Now I tried function
its returning null why??

As I know
returns session.

I know the traditional way of
and else but I want to use Auth->user function why its not working

Answer Source

Please use this to get user session data.

public function login() {
 if ($this->request->is('post')) {
     if ($this->Auth->login()) {
     } else {
    $this->Session->setFlash(__('Invalid username or password, try again'));

public function index() {