diff --git a/route.php b/route.php index f741dd3..e789e1a 100644 --- a/route.php +++ b/route.php @@ -413,6 +413,9 @@ class route try { $data = $function (); + if ($this->method () === "GET" && isset ($_SESSION)) + $_SESSION["domframework"]["route"]["lastGet"] = + "/".$this->requestURL (); } catch (Exception $e) { @@ -467,6 +470,9 @@ class route try { $data = call_user_func_array ($function, $params); + if ($this->method () === "GET" && isset ($_SESSION)) + $_SESSION["domframework"]["route"]["lastGet"] = + "/".$this->requestURL (); } catch (Exception $e) { @@ -596,4 +602,20 @@ class route $output->out ($message, $http->codetext ($getCode)); return true; } + + /** Return the last valid get page to return */ + public function lastValidGetPage () + { + if (isset ($_SESSION["domframework"]["route"]["lastGet"])) + return $_SESSION["domframework"]["route"]["lastGet"]; + return ""; + } + + /** Redirect to last valid get page if defined */ + public function lastValidGetPageRedirect () + { + $lastValidGetPage = $this->lastValidGetPage (); + if ($lastValidGetPage !== "") + $this->redirect ($lastValidGetPage); + } }