Yaf_Response_Abstract::setRedirect

Redirect to another URL

Description

public boolnull Yaf_Response_Abstract::setRedirect(string $url)

Redirect the client to another URL (sends a Location header).

Parameters

url
The URL to redirect to.

Return Values

Returns true on success, or null on failure.

Examples

Example #1 Yaf_Response_Abstract::setRedirect example

<?php
class AccountController extends Yaf_Controller_Abstract
{
    public function indexAction()
    {
        if (!Yaf_Session::getInstance()->has("login")) {
            /* send a Location header pointing to the login page */
            $this->getResponse()->setRedirect("/account/login");
            return false; // nothing to render here
        }
    }
}
?>

See Also

  • Yaf_Controller_Abstract::redirect