【发布时间】:2019-06-15 15:13:36
【问题描述】:
后台 AJAX 调用以 5 秒间隔运行时,CodeIgniter 会话不工作。已使用 Javascript setInterval() 函数设置间隔。 Session Out 将如何处理自动 Ajax 调用?
Javascript 代码:
setInterval(function() {
$.ajax({
url: '../Sadmin/getNotification',
beforeSend: function(){
},
type: 'POST',
dataType:'json',
success: function(response){
if(response.inactive_users.inactive_user=='0'){
$("#inactive_user").removeClass('notify');
}else{
$("#inactive_user").text(response.inactive_users.inactive_user).addClass('notify');
}
if(response.inactive_cp_users.inactive_user=='0'){
$("#inactive_cp_users").removeClass('notify');
}else{
$("#inactive_cp_users").text(response.inactive_cp_users.inactive_user).addClass('notify');
}
if(response.inactive_bp_users.inactive_user=='0'){
$("#inactive_bp_users").removeClass('notify');
}else{
$("#inactive_bp_users").text(response.inactive_bp_users.inactive_user).addClass('notify');
}
if(response.pending_coupon==''){
$("#pending_coupon").removeClass('notify');
}else{
$("#pending_coupon").text(response.pending_coupon).addClass('notify');
}
if(response.pending_bp_coupon==''){
$("#pending_bp_coupon").removeClass('notify');
}else{
$("#pending_bp_coupon").text(response.pending_bp_coupon).addClass('notify');
}
if(response.pending_cp_coupon==''){
$("#pending_cp_coupon").removeClass('notify');
}else{
$("#pending_cp_coupon").text(response.pending_cp_coupon).addClass('notify');
}
if(response.complaints_no=='0'){
$("#complaints_no").removeClass('notify');
}else{
$("#complaints_no").text(response.complaints_no).addClass('notify');
}
},
});
}, 5000);
config.php:
$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 300;
$config['sess_save_path'] = NULL;
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;
这个codeigniter项目的配置文件
【问题讨论】:
标签: ajax session codeigniter-3