会话变量在firefox中无效[PHP]

时间:2016-06-09 16:29:27

标签: php ajax session

我的php应用程序有问题。当我登录时,我调用以下函数设置$ _SESSION变量:

function login($user, $password){
global $server, $owner, $psw, $DB;
if(!($link = mysqli_connect( $server, $owner, $psw, $DB))){
    echo "invalid connection";
}
$user=mysqli_real_escape_string($link, $user);
$password=mysqli_real_escape_string($link, $password);
$password=md5($password);
$query="select email from utenti where password='".$password."' and email='".$user."';";
if(!($res=mysqli_query($link, $query))){
    //echo "invalid query";
    syslog(LOG_ERR,"invalid query");
}
if(mysqli_num_rows($res)==0){
    //echo "login failed";
    syslog(LOG_INFO,"login failed");
    mysqli_free_result($res);
    mysqli_close($link);
    return false;
}
$_SESSION['231587_logged']=true;
$_SESSION['231587_lastvisit']=time();
mysqli_free_result($res);
mysqli_close($link);
return true;
}

在我的客户端,我使用ajax发出一个帖子请求,如下所示:

$.ajax({
            url: url,
            data: "&macchina="+machine+"&inizio="+start,
            method: "POST",
            cache: false,
            success: function (response){
                //document.getElementById("risposta").innerHTML =response;
                //window.location.href = window.location.href; //aggiorna la pagina senza rimandare i dati
                //document.write(response);
                console.log(response);
            },
            error: function (xhr, ajaxOptions, thrownError) {
                alert(xhr.status);
                alert(thrownError);
            }
        });

此请求到达此页面:

if(isset($_POST['macchina'], $_POST['inizio']) && $_SESSION['231587_logged']){
//echo "parametri settati";
if(!stringEmpty()){
    deleteReservation(validateInput($_POST['macchina']), validateInput($_POST['inizio']));
    echo "tornato dalla funzione";
}
}

在Chrome和Microsoft Edge中,一切似乎都运行良好,但在Firefox中,我得到了一个“Undefined index:231587_logged”。你能救我吗?

0 个答案:

没有答案