Why is jquery's .ajax() method not sending my session cookie?

后端 未结 11 1554
长情又很酷
长情又很酷 2020-11-22 02:25

After logging in via $.ajax() to a site, I am trying to send a second $.ajax() request to that site - but when I check the headers sent using FireB

11条回答
  •  自闭症患者
    2020-11-22 03:03

    Perhaps not 100% answering the question, but i stumbled onto this thread in the hope of solving a session problem when ajax-posting a fileupload from the assetmanager of the innovastudio editor. Eventually the solution was simple: they have a flash-uploader. Disabling that (setting

    var flashUpload = false;   
    

    in asset.php) and the lights started blinking again.

    As these problems can be very hard to debug i found that putting something like the following in the upload handler will set you (well, me in this case) on the right track:

    $sn=session_name();
    error_log("session_name: $sn ");
    
    if(isset($_GET[$sn])) error_log("session as GET param");
    if(isset($_POST[$sn])) error_log("session as POST param");
    if(isset($_COOKIE[$sn])) error_log("session as Cookie");
    if(isset($PHPSESSID)) error_log("session as Global");
    

    A dive into the log and I quickly spotted the missing session, where no cookie was sent.

提交回复
热议问题