1

我正在使用 CodeIgniter 2.x 。对于身份验证,我使用的是 flexi auth ( http://haseydesign.com/flexi-auth/ )。我正面临一个可怕的问题。在一个简单的 ajax 请求上,我正在失去会话。

控制器 :

$this->auth = new stdClass;

        // Load 'standard' flexi auth library by default.
        $this->load->library('flexi_auth'); 

        // Check user is logged in as an admin.
        // For security, admin users should always sign in via Password rather than 'Remember me'.
        if (! $this->flexi_auth->is_logged_in_via_password()) 
        {
            // Set a custom error message.
            $this->flexi_auth->set_error_message('You must login as an admin to access this area.', TRUE);
            $this->session->set_flashdata('message', $this->flexi_auth->get_messages());
            redirect('auth');
        }

控制器功能

public function checkItemCode(){

        if($this->input->is_ajax_request()){
            //die('sdasda');
            $getResult = $this->items_model->checkCodeAvailablity();
                if($getResult == false){
                    echo '<span style="color:#f00; margin-left:10px;">This code has been used for another item. Kindly use any other code. </span>';
                }else{
            //echo '<span style="color:#f00">You can use this code!!!</span>';
                }
        } // if
    } // checkItemCode

AJAX 调用

$(document).ready(function() {
    /// make loader hidden in start
    $('#Loading').hide();    

    $('#code').blur(function(){
        $('#Loading').show();
        $.post("<?php echo base_url()?>items/checkItemCode", {
            code: $('#code').val()
        }, function(response){

            $('#Loading').hide();
            setTimeout("finishAjax('Loading', '"+escape(response)+"')", 400);
        });
        return false;
        });

});
function finishAjax(id, response){
  $('#'+id).html(unescape(response));
  $('#'+id).fadeIn();
}

我已经完成了网络上所有可能的选项,如 sess_update 函数、MY_Session lib 等,但没有运气。

请帮帮我。

此致。

4

0 回答 0