If you don't want to use headers, you could set a <meta>
tag to do the redirecting:
$newURL = $this->RedirectURL.'?ErrMsg='.$urlMessage;
echo '<meta http-equiv="refresh" content="0;url='.$newURL.'">';
質問
In my curent project, the header is only loaded once. all the rest of the project add and remove Windows with AJAX method.
Everything works great exept for one detail, since I can't change the header (The page is always loaded). How can I transfer a client to the logon screen if his session had expired?
So far I'm using (in my session class):
public function LoginRedirect() {
//This function will redirect the user to the login page if the session is not valid. Will send GET Reason.
$urlMessage = rawurlencode(utf8_encode($this->ErrMsg));
echo '<script language="javascript"> window.location = "' . $this->RedirectURL . '?ErrMsg=' . $urlMessage . '";</script>';
}
But I dont like using Javascript to redirect a page to the login screen. Is there any other trick I could used?
Thank you
解決
If you don't want to use headers, you could set a <meta>
tag to do the redirecting:
$newURL = $this->RedirectURL.'?ErrMsg='.$urlMessage;
echo '<meta http-equiv="refresh" content="0;url='.$newURL.'">';