您可以在URL本身中传递该URL:
if (!$loggedIn) {
header('Location: http://example.com/login?return='.urlencode($_SERVER['REQUEST_URI']));
exit;
}
Run Code Online (Sandbox Code Playgroud)
并且在成功登录后:
if ($loginSucessful) {
if (isset($_GET['return']) && substr($_GET['return'], 0, 1) == '/')) {
header('Location: http://example.com'.$_GET['return']);
} else {
header('Location: http://example.com/');
}
exit;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
232 次 |
| 最近记录: |