日期:2014-05-17 浏览次数:20539 次
session_start();
if(Login() == true)
{
$_SESSION['login'] = 'ok';
//跳转到page.php
}
else
{
echo "Login error";
}
session_start();
echo $_SESSION['login'];
if(empty($_SESSION['login'])||$_SESSION['login']!='ok') //未登陆则跳回index
{
?><script>setTimeout('window.location="index.php"', 1000);</script><?
}
.....
.....
<script language="javascript">
function goBack()
{
AjaxTest();
window.location.href = "./index.php";
}
function AjaxTest()
{
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request");
return;
}
var url = "ajax.php";
url += "?login=out";
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
alert(xmlHttp.responseText );
}
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)