在ajax电话中丢失了会话

时间:2015-11-06 00:11:51

标签: php ajax

我有一个AJAX调用,用户可以在其中多次订购。我需要得到会话的id,但是这样做会经常调用ajax会话丢失,自动导致'注销',我该如何解决? session_write_close(); // <-- // To allow parallel requests by the same user, while this script is still running.但它不起作用! = /

谢谢!

<?php
    require_once 'connect_db.php';
    require_once 'includes/functions.php';
    sec_session_start();
    $user_id = htmlentities($_SESSION['user_id']);
    session_write_close();
    if(isset($_POST['data_ajax']))
    {
        // do anything
        if (pg_send_query($con,"select * from users where id = $user_id"))
        {
         ...
        }
        $result[]=array("ajax_result"=>"0") //ok
    }
    else
    {
        $result[]=array("ajax_result"=>"1"); // not ok
    }
    echo json_encode($result); 
?>

我使用了本教程 - &gt; wikiHow

0 个答案:

没有答案