Why does my phpsessid is change between 2 ajax requests

I use 2 ajax requests to communicate to my other site

first : authenticate to the site
second : get the data base on user authentication

When I create the user session in first request the session is created, but I only get null data when I request the data because user session is lost.

This does not happen if I test it by manually filling in the url address in browser.

I see the phpssid is changed : PHPSESSID

ajax request :

var url = 'https://xxx.mysite.co.id/index.php/';
$(document).ready(function(){
    $.ajax({
        url: url+"main/authenticate_user/user/123456/undefined/11",
        dataType : 'json',
        beforeSend: function(xhr){
           xhr.withCredentials = true;
        },
        success: function(authenticate){
            if(authenticate.state == 'success'){
                $.ajax({
                    url: authenticate.url,
                    dataType : 'text',
                    beforeSend: function(xhr){
                       xhr.withCredentials = true;
                    },
                    success: function(login){
                        $.ajax({
                            url: url+"main/module/lead/get_data/lead_id/LEAD26016",
                            dataType : 'json',
                            beforeSend: function(xhr){
                               xhr.withCredentials = true;
                            },
                            success: function(lead){
                                $.ajax({
                                    url: authenticate.url,
                                    dataType : 'text',
                                    beforeSend: function(xhr){
                                       xhr.withCredentials = true;
                                    },
                                    success: function(login){
                                        $.ajax({
                                            url: url+"main/module/lead/get_data/lead_id/LEAD26016",
                                            dataType : 'json',
                                            beforeSend: function(xhr){
                                               xhr.withCredentials = true;
                                            },
                                            success: function(lead){
                                            }
                                        });

                                    }
                                });
                            }
                        });

                    }
                });
            }
        }
    });
});

i request from hxxp://localhost/

Updated : i really stuck for this problem, i just change the session process to my own filecache class.

链接地址: http://www.djcxy.com/p/55310.html

上一篇: 发布Ajax函数返回true或false

下一篇: 为什么我的phpsessid是2个Ajax请求之间的变化