在PHP中将会话变量传递到多个页面

在PHP中将会话变量传递到多个页面,php,session,Php,Session,我使用这个简单的登录脚本创建一个简单的面板: 我的问题是,我不能将$\u会话变量传递到多个页面。我希望用户看到多个页面 这是我代码的一部分: // ... ask if we are logged in here: if ($login->isUserLoggedIn() == true) { // the user is logged in. you can do whatever you want here. // for demonstration purpose

我使用这个简单的登录脚本创建一个简单的面板:

我的问题是,我不能将$\u会话变量传递到多个页面。我希望用户看到多个页面

这是我代码的一部分:

 // ... ask if we are logged in here:
if ($login->isUserLoggedIn() == true) {
    // the user is logged in. you can do whatever you want here.
    // for demonstration purposes, we simply show the "you are logged in" view.
    include("views/logged_in.php");
} else {
    // the user is not logged in. you can do whatever you want here.
    // for demonstration purposes, we simply show the "you are not logged in" view.
    include("views/not_logged_in.php");
}

即使我包含example.php,它仍然不起作用。

OT:我快速查看了这个简单的包。。。它的sql注入保护也岌岌可危。除非您确定自己不属于不良边缘情况,否则使用它不会被认为是安全的。该库的作者真的应该使用准备好的语句更新他的代码。在其他页面上,要获取$\u会话变量,只需
SESSION\u start()位于这些页面的顶部。这要求用户在BTW上拥有cookie。