先看登录进去后的页面content.php
<?php
//error_reporting(E_ALL ^ E_NOTICE);
if (isset($_SESSION)){
session_start();
}
include("checklogin.php");
?>
欢迎页面,说明已经登录进来
<?php
if ($_GET['out']){
unset($_SESSION['username']);
}
?>
<a href='?out=index'>退出</a>checklogin.php页面是<?php
//error_reporting(E_ALL ^ E_NOTICE);
session_start(); if ($_SESSION['username']==""){
echo "<script language='javascript'>alert('对不起,需要登录才能访问次页面');" .
"window.location.href='index.php';</script>";
}
?>我登录进去后,页面地址是......content.php,点击页面的退出,页面地址变为.....content.php?out=index 页面没有变化,再次点退出才跳转到登录界面,也就是说我要点2次退出,页面才会跳转 这是怎么回事
还有 万恶的Notice又出现 Notice: Undefined index: out
Notice: Undefined index: username
<?php
//error_reporting(E_ALL ^ E_NOTICE);
if (isset($_SESSION)){
session_start();
}
include("checklogin.php");
?>
欢迎页面,说明已经登录进来
<?php
if ($_GET['out']){
unset($_SESSION['username']);
}
?>
<a href='?out=index'>退出</a>checklogin.php页面是<?php
//error_reporting(E_ALL ^ E_NOTICE);
session_start(); if ($_SESSION['username']==""){
echo "<script language='javascript'>alert('对不起,需要登录才能访问次页面');" .
"window.location.href='index.php';</script>";
}
?>我登录进去后,页面地址是......content.php,点击页面的退出,页面地址变为.....content.php?out=index 页面没有变化,再次点退出才跳转到登录界面,也就是说我要点2次退出,页面才会跳转 这是怎么回事
还有 万恶的Notice又出现 Notice: Undefined index: out
Notice: Undefined index: username
当退出的时候 销毁session就可以了。然后跳转到你的登录页面
<?php
session_start();
isset($_SESSION['username'])?include("checklogin.php"):session_destroy();
?>欢迎页面,说明已经登录进来
<?php
if (isset($_GET['out'])){
$_GET['out']=='index'?session_destroy():'';
}
?>
<a href='?out=index'>退出</a>checklogin.php页面是<?php
//session_start();
if (empty($_SESSION['username'])){
echo '你的js提示';
session_destroy();
}?>