PHP Session variable not getting set

To solve this problem, you will need to:

1) Ensure that session_start() is called at the beginning of the script, before anything else.

2) Nothing is unsetting $_SESSION or $_SESSION['returnURL'].


first.php

<?php
session_start();
$_SESSION['returnURL'] = "/store/checkout/onepage";
echo '<a href="second.php">Pass session to another page</a>';
?>

second.php

<?php
session_start();
echo 'returnURL = ' . $_SESSION['returnURL'];
?>

So you need to write session_start() in both your files

Tags:

Php

Session