Session Variable Problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
SAPHP
Forum Newbie
Posts: 1
Joined: Fri Sep 02, 2005 8:42 am

Session Variable Problem

Post 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
User avatar
Skittlewidth
Forum Contributor
Posts: 389
Joined: Wed Nov 06, 2002 9:18 am
Location: Kent, UK

Post 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'];
?>
Post Reply