我有头问题不能正常工作..重定向使用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...
格式的代码正确 –