Yaf_Response_Abstract::setRedirect

(Yaf >=1.0.0)

Yaf_Response_Abstract::setRedirectRedirect to another URL

Description

public function Yaf_Response_Abstract::setRedirect(string $url): ?bool

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

add a note

User Contributed Notes

There are no user contributed notes for this page.