I'm trying to save value to php session using post into jquery. Below jquery code:
$.ajax({
url: callPHPFuncURL,
type: 'POST',
async: false,
timeout: 30000,
data: {methodName: 'moveschedulerhorizont',
forward: forward
},
dataType: 'json'
}).done(function (data) {
if (data.success === true) {
isOK = data.success;
}
isOK = true;
});
Below moveschedulerhorizont method:
$forward = $_POST['forward'];
$scheduler = new Scheduler();
$isOK = $scheduler->set_firstDate($forward);
And below set_firstDate method:
$dt = new DateTime($this->firstDateTime);
$dt->add(new DateInterval('P' . ($this->skipHorizont * 7) . 'D'));
$_SESSION['StartDate'] = $dt->format('Y-m-d');
The part that calculates date returns the correct value. But value isn't save to session. Session_start() is called in other part of code.
The strangest this is that i save startDate to session, but when page is generated. But later when i use jquery it doesn't work :(