diff --git a/src/FuzeWorks/Output.php b/src/FuzeWorks/Output.php index fbca4ea..ca50b7c 100644 --- a/src/FuzeWorks/Output.php +++ b/src/FuzeWorks/Output.php @@ -522,4 +522,25 @@ class Output } } + + /** + * Set the location to redirect the user to. + * + * @param string $locationUrl Should be prepended with / + * @param bool $permanent True for 301, false for 302 redirect. + * @return void + */ + public function setLocation(string $locationUrl, bool $permanent = false) + { + // Set the status header + if ($permanent) + $this->setStatusHeader(301); + else + $this->setStatusHeader(302); + + // And the location itself + $header = 'Location: ' . $locationUrl; + $this->headers[] = [$header, true]; + } + } \ No newline at end of file