Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/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_Codeigniter_Session - Fatal编程技术网

Php 会话到期时不显示登录页面

Php 会话到期时不显示登录页面,php,codeigniter,session,Php,Codeigniter,Session,我有一个使用codeigniter开发的项目 在这种情况下,当会话到期时,我需要重定向到登录页面。 控制器文件 //继承父构造函数 父项::_构造() //检查它是否是ajax调用 如果($this->input->is\u ajax\u request()) { //检查会话是否存在 $status=$this->common_functions->verify_session('ajax_调用'); //如果会话不存在 如果(!$状态) { //返回json e

我有一个使用codeigniter开发的项目

在这种情况下,当会话到期时,我需要重定向到登录页面。 控制器文件

//继承父构造函数 父项::_构造()

//检查它是否是ajax调用
如果($this->input->is\u ajax\u request())
{
//检查会话是否存在
$status=$this->common_functions->verify_session('ajax_调用');
//如果会话不存在
如果(!$状态)
{               
//返回json
echo json_encode(数组(“会话超时”=>“true”,“消息”=>“会话超时。请再次登录”);
//出口
出口
}
}
其他的
{
//初始化私有属性
$this->_section='';
//检查会话是否存在
$this->common_functions->verify_session();
}
共同作用


我有代码可以重定向到登录页面

您可以添加您在“公共函数”中编写的内容吗?在公共函数中,我有代码可以重定向用户到登录页面,我检查了代码是否可以与其他控制器文件正常工作。对于ajax请求,您必须使用类似top.location.href='xxxxxxx'的内容进行重定向。你考虑到这一点了吗?
    //check whether it is an ajax call or not
    if($this->input->is_ajax_request())
    {
        //check the session exist or not
        $status = $this->common_functions->verify_session('ajax_call');

        //if session doesnot exist
        if(! $status)
        {               
            //return the json
            echo json_encode(array("session_timeout"=>"true", "msg"=>"<h3>Session timed out.</h3> Please login once again."));

            //exit
            exit;
        }
    }
    else 
    {
        //Initialize the private property
        $this->_section = '';

        //check the session exist or not
        $this->common_functions->verify_session();

    }