我正在使用PHP/MySQL,並且我想知道使未經身份驗證的用戶登錄的最佳方式,然後讓它們自動重定向到他們登錄的頁面登錄Interupt並使用PHP/MySQL返回到頁面
例如:
1)用戶試圖打開安全頁面。
2)它們被重新定向並提示登錄。
3)成功登錄後,它們被帶回他們嘗試訪問的URL。
目前,在我的「安全」頁面,我有以下的PHP代碼設置:(甚至不知道這是正確的方式做「安全」的話):
<?php
session_start();
if ($_SESSION['first'] == "" && $_SESSION['usrID'] == "") {
print" <script>
window.location=\"../login/index.php\"
</script> ";
}
?>
任何的建議如何提供此功能(並可能使我的'安全'代碼更好),我將不勝感激。
謝謝!