hi.

RequestHandler will be discontinued
http://book.cakephp.org/2.0/en/appendices/2-0-migration-guide.html#requesthandlercomponent

<?php class TestsController extends AppController {
 public function beforeFilter(){
$this->Auth->allow('add');
parent::beforeFilter();
}
 public function add(){
if($this->Auth->loggedIn()){  // or if($this->Auth->User())
 $return['data'] = 'data';
 }
// if the session expired, $return is not defined
if(!isset($return)){
$return['login'] = true;
}
$this->set('return',$return);
$this->render('ajax_view','ajax');
}
}
?>

/View/Tests/ajax_view.ctp
<?php
if(isset($return)){
echo json_encode($return);
}
?>


Greetings

2012/8/30 Florin Trifu <[email protected]>

> Hi everyone!
>
> I have the following problem: in my application I have a button that makes
> an ajax request. If the session expired, the lightbox will load the default
> login page. I want to detect if the original request came from Ajax but I
> don't know exactly how to do it, because in app_controller::beforeFilter
> the request is not Ajax anymore (at least according to
> $this->RequestHandler->isAjax() ). I have tried to use
> $this->Auth->ajaxLogin to set a new view for the login if the request comes
> from an expired session.
>
> Thank you!
>
> Best regards!
>
> --
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.


Reply via email to