Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Access to Auth Componenet using session in CakePhp

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 112
    Comment on it

    To access the Auth component from view will give you error like you cant access the Auth component.

    Here is a way of accessing the Auth components from view which can be done using CakeSession in cakephp. to do so lets see the example :

     $user =  CakeSession::read("Auth.User.id");;
    if ($user){
    // do something
    }
    

    Using the CakeSession to access the Auth components to read the user id from it. But this method is not recommended or we can say is not the proper way. To work on the Auth components in proper way we can do as:

    $user = $this->Session->read('Auth.User');
    if ($user){
    // do something
    }
    

    Using the Session component we can read the Auth components. The Auth components are stored in the Session so, with the session we can access the Auth components.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: