Friday, August 31, 2012

Re: Cakephp 1.3 - Detect if Ajax if session expired

hi 


<?php class AppController extends Controller {

public function beforeFilter(){
if ($this->Auth->User()){
}else{
if($this->params['isAjax']){
// if the session expired
$return['login'] = true;
echo json_encode($return); // responseText: "{"login":true}"
}
}
}
} ?>

Best regards!

2012/8/31 Florin Trifu <florin.catalin.trifu@gmail.com>
Thank you!

This is how I have tried in the first place but it is not working. $this->RequestHandler->isAjax() is null or false, so it will never execute the conditional code.

Best regards!

--
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-US.
 
 

--
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-US.
 
 

No comments: