Using $ _session with jquery ajax

0

I am trying to hide a php using $_SESSION but it seems that it does not pass the first file. Here I show my files:

ajax.php

$('.button').click(function(){
    var value = $('#valor').val()

    $.ajax({
             type: "POST", 
             url: "salvar.php", 
             data: {valor: value},
             success: function(response) { 
                 console.log(response); 
             }
    }); 
}); 

salvar.php

<?php
    session_start();

    $_SESSION['valor'] = $_POST['valor']; 
?>

query.php

<?php
    session_start(); 

    if (isset($_SESSION['valor'])){ echo 'si'};
    else {echo 'nop'};
?>

If I put a echo in save it shows me the variable in the answer of the ajax, but if I leave the echo of the query nothing happens, what am I doing wrong?

Thanks in advance.

    
asked by Nikolas Tenorio Osorio 19.09.2018 в 16:32
source

0 answers