我无法在我的php页面上访问我的链接

the*_*aps 0 php

我正在view_category.php为我的论坛工作一个页面但是我遇到一个小问题我的链接无法正常工作我正在登录但页面显示我没有登录它对待我就像我是一个客人只是查看论坛因此我无法在论坛上创建主题,我的create_topic.php链接无法访问.

这是我的代码如下

// Assign local variables
$cid = $_GET['cid'];

// Check to see if the person accessing this page is logged in
if (isset($_SESSION['uid'])) {
    $logged = " | <a href='create_topic.php?cid=".$cid."'>Click Here To Create A Topic</a>";
} else {
    $logged = " | Please log in to create topics in this forum.";
}
Run Code Online (Sandbox Code Playgroud)

为什么会这样?

我刚才包括在内

var_dump($_SESSION); 
Run Code Online (Sandbox Code Playgroud)

这就是输出

 array(2) { ["username"]=> string(7) "mura" ["password"]=> string(4) "1234" }
Run Code Online (Sandbox Code Playgroud)

Has*_*ast 7

放在session_start();你的文件的标题

  • 那是你的问题; 您的会话中不存在`$ _SESSION ['uid']`.你的意思是使用`$ _SESSION ['username']`,还是想在登录时设置uid? (2认同)