我有一個index.html文件,我想在加載時運行一些jQuery。基本上,我想檢查用戶是否已經基於某些會話變量登錄。要發佈到php文件的jQuery
所以index.html的將包含一些jQuery的,它使用$(document).ready(function(){ });
在這個功能我想剛剛火autheticate.php進行檢查,看是否$ _SESSION [「用戶」]設置,如果是則將重定向到主頁,否則將重定向到登錄頁面...
如何在jQuery中發佈而無需html表單?我只是想張貼到網址...
編輯:
基於@ jondavidjohn的答案,我改變了我的web應用程序,以便它使用的index.php檢查會話:
<?php
session_start();
if(isset($_SESSION['username'])){
//go to home page
header('Location: ...home.html');
}else{
//go to login page
header('Location: ...login.html');
}
?>
+1爲正確的方式來處理此問題。 –