I am retrieving some log in details from a web service, and once collected i need to save these values to session cookies, and then use them to verify a user and then on a form.
But it seems that i can post the values to the page, but the values seems to clear before i can use them
So I have this in ajax.
function onDataReceived(data)
{
if (data != 0){
var stuff = data;
var split = stuff.split("/");
$.ajax({
type: "POST",
url:"save_Session.php",
data: {ID: split[0], EMAIL: email, NAME: split[1], COMPANY: split[2]},
success:function() {
location.href='https://www.mysite.com/result.php';
}
})};
save_Session.php
<?php
session_start();
$_SESSION["user"] = isset($_POST['ID']) ? $_POST['ID'] : '';
$_SESSION["email"] = isset($_POST['EMAIL']) ? $_POST['EMAIL'] : '';
$_SESSION["name"] = isset($_POST['NAME']) ? $_POST['NAME'] : '';
$_SESSION["company"] = isset($_POST['COMPANY']) ? $_POST['COMPANY'] : '';
?>
Then on the page I need them I have this, but when I echo them out there nothing there.
result.php
<?php
error_reporting(E_ALL);
ini_set('display_errors','Off');
session_start();
$userID=$_SESSION["user"];
$userEmail=$_SESSION["email"];
$userName=$_SESSION["Name"];
$userCompany=$_SESSION["company"];
echo ($userID." - ID; ");
echo ($userEmail." - email; ");
echo ($userName." - name; ");
echo ($userCompany." - company; ");
?>
Droopsnoot in the php forum has suggested that when iām posting the values onto the php page, that once that session is done it closes the session down and so clears the cookies, i agree but the trouble is i dont know how to get around it, as these values are quite critical to the site