Page 1 of 1

Session Variable Problem

Posted: Fri Sep 02, 2005 8:47 am
by SAPHP
Hi
i want to use SESSION Variables but i cant get the Variable Value
on other Pages.
here is my code:

Page 1:

Code: Select all

<?PHP
 session_start();
  $name = "John";
 $_SESSION["name"] = $name;
 print("Please Visite <a href=\"./mysession.php\">This</a> Link.");
?>
Page 2:

Code: Select all

<?PHP
 echo $_SESSION["name"];
?>
Page 2 Do not Print Anything!
whats the Problem? :?:

Burrito: Please use php tags when Posting Code In The Forums

Posted: Fri Sep 02, 2005 8:52 am
by Skittlewidth
Page two needs to have session_start(); at the top as well to continue the session:

Code: Select all

<?php
session_start();
 echo $_SESSION['name'];
?>