我有设置会话的代码,例如:
if($found>0){
session_start();
$_SESSION['user_name']=$user;
session_set_cookie_params(24*60*1,'/','.localhost');
$expire=time()+60*60*24;
setcookie("cookiename", $user, $expire);
header("location:http://localhost/UI/user/userprofile.php");
} else{
$message = "Username or password is not correct.";
header("Location:index.php?message={$message}");
}
这是我在其中放置登录和注销的标题内容
session_start();
if (isset($_COOKIE["cookiename"])){
$unm = $_SESSION["user_name"];
echo "User : " . $_SESSION["user_name"] . "";
echo " <a href='http://localhost/UI/user/logout.php'>logout</a>";
echo " <a class='addmeeting' href='http://localhost/UI/user/createmeeting.php' title='Create New Meeting'>Create Meeting</a>";
} else{
echo "<li><a href='register.php'>Register</a></li>";
echo " User : Guest!<br />";
}
我的会话适用于子文件夹,但不适用于父文件夹。这是目录结构:
UI
user
userprofile.php
login.php
logout.php
index.php
headers.php
请告诉我我做错了什么?