Added Request::redirect() as a redirect helper
This commit is contained in:
parent
117033252f
commit
3438d2a5ef
|
@ -592,6 +592,28 @@ class Request_Core {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Redirects as the request response.
|
||||||
|
*
|
||||||
|
* @param string redirect location
|
||||||
|
* @param integer status code
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function redirect($url, $code = 302)
|
||||||
|
{
|
||||||
|
// Set the response status
|
||||||
|
$this->status = $code;
|
||||||
|
|
||||||
|
// Set the location header
|
||||||
|
$this->set_header('location', $url);
|
||||||
|
|
||||||
|
// Send headers
|
||||||
|
$this->send_headers();
|
||||||
|
|
||||||
|
// Stop execution
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a file as the request response.
|
* Sends a file as the request response.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue