我有頭問題不能正常工作..重定向使用header()函數,同時檢查會話
我工作的登錄功能......在
1)如果用戶登錄自己的/她的證書......
2)用戶後嘗試打開新的標籤頁,然後鍵入LoginViewController.php ..
3)在這裏,我需要將用戶重定向到以前的登錄page..based上seesion active ..
對4)但頭不重定向到loggedin.php頁..並表現出一些空白頁..
Here is the LoginViewController.php
<?php
session_start();
include('GenericClasses/GenericCollectionClass.php');
include('Models/UsersModel.php');
include('DataObjects/Users.php');
include('DatabaseAccess/DBHandler.php');
if(!empty($_SESSION['user']))// Here checking session is empty or not
{
header("Location : loggedin.php");// Here it is not redirecting properly
die();
}
else
{
}?>
這裏是loggin.php
<?php
session_start();
header("Cache-Control: private, must-revalidate, max-age=0");
header("Pragma: no-cache");
header("Expires: Fri, 4 Jun 2010 12:00:00 GMT");
include('GenericClasses/GenericCollectionClass.php');
include('Models/UsersModel.php');
include('DataObjects/Users.php');
include('DatabaseAccess/DBHandler.php');
if(!isset($_SESSION['user']))
{
header('Location: LoginViewController.php');
exit();
}
echo '<div style="background:white; text-align:right"> Login as:'.$_SESSION['user'].'<a href="LogoutViewController.php" style="text-align:right">Logout</a></div>';
?>
Any suggestions are acceptable...
格式的代碼正確 –