This question might seem a duplicate and There are many posts on how to pass jquery variables to php. Tried all of them none worked for me.
Here is what all I did.
From Jquery:
$.ajax({
url: '/test.php',
data: {"name":name,"phone":phone},
type: 'post',
success:function(data){
console.log("Succses");
}
});
In test.php
session_start();
$_SESSION['name'] = $_POST['name'];
$_SESSION['phone']=$_POST['phone'];
There is nothing complex in this code. It is so simple and am seeing the "Success" message on the console. When am trying to echo this sssion variable in another page, this is shown empty.
Any help is greatly appreciated.