I have been performing session creation using PHP. I'm trying to create session using AJAX call.
This is my ajax call code :
var xhr = new XMLHttpRequest();
xhr.open('POST', 'https://www.vedarjana.com/signin.php');
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.onload = function() {
console.log('Signed in as: ' + xhr.responseText);
};
xhr.send('id=' + "123");
xhr.onreadystatechange = function() {
if (xhr.readyState == XMLHttpRequest.DONE) {
if (xhr.responseText == '') {
//alert(xhr.responseText);
} else {
location.reload();
}
}
}
Now This is my PHP code for session generation :
session_start();
$_SESSION["frontUserIslogin"] = true;
$_SESSION["frontUserId"] = "123";
$_SESSION["frontUserName"] = "abc";
$_SESSION["frontUserProfilePic"] = "abc.png";
echo $_SESSION["frontUserName"];
Now when I perform AJAX call, session is generating as its returning username. But when page reloads, I'm checking var_dump($_SESSION)
then its showing NULL
Please help me I'm stuck on it from last 3 weeks
Thanks in advance