Interesting -  to my knowledge, beforeFilter is called whenever you
request a page through the dispatcher, so any calls to requestAction
in your view or controller may cause beforeFilter to trigger again.

Rather than logging "$this->log('login->beforefilter():'.$this->bft.
$this->name); "
Try logging the actual action that was called, i.e $this->action, to
see what triggered the beforeFilter.

Wood

On Feb 22, 7:42 am, "pieceofcakephp" <[EMAIL PROTECTED]> wrote:
> I have this code (below), but when it run fromhttp://localhost/app/users/login
> I see the log for function "beforefilter()" call 3 times
>
> 2007-02-22 14:32:44 Error: login->beforefilter():0Users
> 2007-02-22 14:32:44 Error: defaultX.X.XUsers
> 2007-02-22 14:32:44 Error: login():Users
> 2007-02-22 14:32:44 Error: login->beforefilter():0Users
> 2007-02-22 14:32:44 Error: defaultX.X.XUsers
> 2007-02-22 14:32:45 Error: login->beforefilter():0Users
> 2007-02-22 14:32:45 Error: defaultX.X.XUsers
>
> is this default behaviour?
> I am using the latest 1.2 from svn
>
> Regards, Widi
>
> <?php
> class UsersController extends AppController {
>     var $name = 'Users';
>     var $bft  = 0;
>         function beforefilter(){
>                 $this->log('login->beforefilter():'.$this->bft.$this->name);
>                 $this->bft = $this->bft + 1;
>                 $this->defaultVars();  // app_controller.php
>         }
>         function login(){
>                 $this->log('login():'.$this->name);
>                 $this->viewVars['csss'][] = 'forms';
>         $this->set('error', false);
>         if (!empty($this->data) && isset($this->data['User'])){
>             $someone = $this->User->findByUsername($this->data['User']
> ['username']);
>             if(!empty($someone['User']['password'])
>                    && $someone['User']['password']==
>                    $this->data['User']['password']){
>                                 $this->saveLastLogin($someone['User']['id']);
>                 $this->Session->write('User', $someone['User']);
>                                 $url = 
> 'http://'.$_SERVER['HTTP_HOST'].$this->webroot;
>                 $this->redirect($url.'articles');
>                 $this->log(print_r($someone,LOG_DEBUG));
>             } else {
>                 $this->set('error', true);
>             }
>         }
>     }


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to