Free Android CakePHP GMaps Articles by Bali Web Design

October 28, 2010

Redirect with exit using cakephp

Filed under: cakephp,php — admin @ 8:38 am

If you run redirect function on cakephp 1.1, don’t forget to add exit() function after redirect sintax. This thing can make security hole that confusing you. The purpose of adding exit() function after redirect sintax is to avoid php running others code after redirect function.

$this->redirect('controller/action');
exit();

However cakephp 1.2 give you default exit after redirect. The complete sintax for redirect on cakephp 1.2 is

$this->redirect('controller/action', null, true);

which the third parameter define exit = true, means terminate the script. second parameter is for setting exit status, for example 404, etc. Defaultly you only need to write

$this->redirect('controller/action');


No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment