我正在使用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 CALL
$(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等等,但没有运气。
请帮助我。
最诚挚的问候。