Wednesday, September 26, 2012

Re: function beforeFilter

hi Jeremy,... can't access the site (secure area) with username and password,... loosing session I think,... can't read user,... and   function beforeFilter()  is in a app-controller.php with settings 

  var $helpers = array('Html', 'Form', 'Time', 'Text', 'Javascript', 'Ajax', 'Session', 'Application', 'User', 'PhotoShow');  
    var $components = array('Cookie', 'RequestHandler', 'Session');
  


On Wednesday, September 26, 2012 5:10:17 AM UTC-7, Chris wrote:
function beforeFilter working on a 1.2,... trying to migrate whole script to 1.3,... 
having problem,... what can be wrong,... ??? please help,... thanks 

  
  function beforeFilter()
  {
    if($this->Session->check('user'))
      $this->user = $this->Session->read('user');
    
    if(!$this->is_user())
    {
      $username = $this->Cookie->read('User.username');
      $hashed_password = $this->Cookie->read('User.hashed_password');
      
      if($username && $hashed_password)
      {
        if(!class_exists('User'))
          loadModel('user');
          
        $User = new User();
        
        if($user = $User->findByUsernameAndHashedPassword($username, $hashed_password))
        {
          $this->Session->write('user', array('id' => $user['User']['id'], 'username' => $user['User']['username'], 'rank' => $user['User']['rank'], 'gender' => $user['User']['gender'], 'firstname' => $user['User']['firstname'], 'lastname' => $user['User']['lastname']));
          $this->set_language($user['User']['language']);
          if($this->Session->check('user'))
            $this->user = $this->Session->read('user');
        }
      }
    }
    


--
Like Us on FacekBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

No comments: