I have an event listener on an input that executes an ajax request to set PHP session variable.
This works on the first event trigger, but after that, the PHP session variable remains unchanged.
This is my PHP chunk
session_start();
if(isset($_GET['driver'])){
$driver = $_GET['driver'];
$_SESSION['driver'] = $driver;
}
This is my javascript
$('#save').change(function() {
$.ajax({
url: 'index.php',
method: 'GET',
data: {
'driver': 'example'
}
});
This is my console log. Starting with the first change trigger. I am using dump_session to output the contents of the php variables. Right before the "Attempting ajax request" would be the new modified inputs that are being sent in the ajax request.
builder.js:168 (2) [_.P, _.P]
builder.js:170 ["Galerías Toluca"]
builder.js:171 Attempting ajax request
builder.js:318 array(2) {
["destinos"]=>
string(22) "["GalerÃas Toluca"]"
["markers"]=>
string(82) "[{"lat":19.2889701,"lng":-99.61342109999998},{"lat":19.2898867,"lng":-99.6226059}]"
}
builder.js:168 (3) [_.P, _.P, _.P]
builder.js:170 (2) ["Galerías Toluca", "IEDIS TOLUCA"]
builder.js:171 Attempting ajax request
builder.js:318 array(2) {
["destinos"]=>
string(22) "["GalerÃas Toluca"]"
["markers"]=>
string(82) "[{"lat":19.2889701,"lng":-99.61342109999998},{"lat":19.2898867,"lng":-99.6226059}]"
}
I assume that you already used unset($_SESSION['driver']);
before update $_SESSION['driver'] = $driver;
and the problem still the same