Hey Everyone - I have a question about PHP Sessions. within my code, I am trying to get a value from a URL parameter and store it in a session. <?php //get event value from URL $event = $_GET['event']; //Start Session and set it equal to parameter session_start(); $_SESSION['event'] = $event; ?> PHP: I want to get the value from the session on another page and use it in my logic. <?php echo "event value = ". $_SESSION['event']; ?> PHP: I am not getting any value from the session value. The code displays "event value = ". Am I doing something wrong? Thanks
On the second page you need to have the session_start(); on top of it. If it does I would try displaying it on the page where it was set and go from there.
Thanks Guys....I tried adding session_start() to the second page and I still have the same problem. On the first page I am setting the session value then redirecting to a new page with header (); header("Location: http://www.myurl.com/parent_signup.php"); PHP: Does that have anything to do with it? Thanks
That shouldn't have any thing to do with it. I just tested it with a header redirect and it worked fine.
Try these one.php <?php session_start(); $_SESSION['fruit'] = 'apple'; header('Location: two.php'); ?> PHP: two.php <?php session_start(); var_dump($_SESSION['fruit']); ?> PHP: