Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如果我以注册用户的身份登录我的网站,在设置会话规则后,我怎么会无法访问其他页面?_Php_Session Variables - Fatal编程技术网

Php 如果我以注册用户的身份登录我的网站,在设置会话规则后,我怎么会无法访问其他页面?

Php 如果我以注册用户的身份登录我的网站,在设置会话规则后,我怎么会无法访问其他页面?,php,session-variables,Php,Session Variables,我现在正在处理一个项目,如果我以用户身份登录,我将无法访问我个人资料的页面-我已在每个页面的顶部设置了此I规则: if(!isset($_SESSION['loggedin'])) header("location:http://localhost/ci/web-project-jb.php/start");// If an unregistered user tries to manually navigate to any of my webpages they will be broug

我现在正在处理一个项目,如果我以用户身份登录,我将无法访问我个人资料的页面-我已在每个页面的顶部设置了此I规则:

 if(!isset($_SESSION['loggedin']))
header("location:http://localhost/ci/web-project-jb.php/start");// If an unregistered user tries to manually navigate to any of my webpages they will be brought to 'start' page. 
起始页已关闭

 <$_SESSION['username'] = null;?> 

我有一个会话_start();在我登录后在我的主页上(也在我的登录页面上),但是既然我已经把上面的if语句放进了我的主页,我就不能再以注册用户的身份登录了——为什么会发生这种情况?我甚至在登录页面上调用了session_start。再次感谢您的帮助

您在哪里将
$\u SESSION['loggedin']
设置为
TRUE
?是否应在每页上设置此设置?会话_start();如果(!isset($_SESSION['loggedin']==true));标题(“location:);?>session_start()必须位于需要使用$_session的每个页面上,或者位于每个页面上包含的php文件中。好的,我已将其放入-if(!isset($_session['loggedin'])&&&$_session['loggedin']=true)标题(“location:);。但如果现在成功登录到主页,它会给我一个错误-未定义的索引:loggedin上述永远不会是真的。您不能将
$\u会话['loggedin']
设置为未设置,也不能将其设置为
true
function logout()
{
$this->session->sess_destroy();
redirect ('start');
}