2012-08-07 112 views
0

我在我的视图中开发了以下js。在codeigniter中的ajax调用后重新生成新的会话ID

var url  = '<?php echo base_url(); ?>edit/'; 
$(document).ready(function(){ 
    $("#ajax-loader").hide(); 
    $("#personaldetails-en-di-icon").click(function(){ 
     $("#ajax-loader").show(); 
     $.post(url+'ajax/personaldetails/enable', {}, function(data){ 
      console.log(data); 
     }); 
    }); 
}); 

所以,当我点击时,它请求编辑控制器。

在编辑控制器我有 private $ id = null;

public function __construct() { 
    parent::__construct(); 
    $this->load->library('session'); 
    $this->load->library('input'); 
    $this->load->model('editcv_model'); 
    $this->load->helper('url'); 

    $this->id = $this->session->userdata('login');   
    if (intval($this->id) < 1) 
     die(json_encode(array('response' => 'not logged in'))); 
    } 

    public function _remap($method = '',$param = array()){ 
     echo (json_encode(array('response' => 'done'))); 
    } 
} 

第一AJAX调用回波{ “响应”: “完成”}在铬控制台,但第二和其它请求回声{ “响应”: “在没有登录”}。 当我检查在phpMyAdmin会话表,它会重新生成会话ID,与其他用户代理

enter image description here

,你看到的Mozilla/5.0(X11; Linux的i686的)为AppleWebKit/537.1(KHTML,例如Gecko )Chrome/21.0.1180.57 Safari/537.1 AlexaToolbar/alxg-3更改为Mozilla/4.0(兼容; MSIE 7.0; Windows NT 6.0)AlexaToolbar/alxg-3.0在ajax request.but我使用谷歌Chrome浏览器的Ubuntu! !!。

+0

我不知道如何在CodeIgniter中设置会话名,但可以尝试一次'session_name()'函数。 – 2012-08-07 07:21:57

+0

什么是'_remap' _function_在构造函数中做什么? O_O 函数可以在构造函数内吗? _masaka_ – Prasanth 2012-08-07 09:08:57

+0

确保编辑控制器正在执行session_start()。 – Brian 2012-08-07 12:58:18

回答