您好每次刷新或点击重新加载我的索引页面的按钮...这是我的主页面,会话终止....这里是一个简单的代码:
//session.class.php
<?php
session_start();
$_SESSION["EMAIL"] = "";
$_SESSION["LOGED"] = 0;
?>
//index.php
<?php
include_once ('session.class.php');
if (isset($_GET['login'])) {/// it a button submit in my form that use for login
$_SESSION["LOGED"] = 1;
include ("/module/Users/profile.php");// class that show profile if login an
// password is good
echo "session = ".$_SESSION["LOGED"];
}
if ($_SESSION["LOGED"] == 0) {
echo userFormLogin();//show login
echo "<a href=index.php?content=register>Register</a>";
}
?>
TY每一个:D
答案 0 :(得分:1)
每次加载页面时,您的EMAIL和LOGED会话变量都会重置。您不需要申报,SESSIONS在您创建之前不会存在。您基本上是创建会话,但是当您加载页面时,它被设置为0并且您再次要求登录。
您应该使用:
if(isset($_SESSION['LOGED'])){
actions for logged in
}
else{
show login page
}