... and my marbles. I am transfering session variable from page to page, well, at least I'm trying to. I am having users go through a web site in a very structured way. That is, the site has a beginning and an end. As a result, I need to keep track of the users current location and the farthest point attained in the site. The current point and farthest point attained will control the activation and deactivation of links to other sections within the site. Now I can pass the $_SESSION['variables'] to the first page, but after that the variables are lost. Here is what I have:
-----------------------------LogInProcess.php--------------
/*Processes the login information that is received from the login page */
<?php
session_start();
$register = session_register("firstName", "lastName", "currentPage", "lastPage"
;
$firstName = $_POST['firstName'];
$lastName = $_POST['lastName'];
$currentPage = $_POST['currentPage'];
$lastPage = $_POST['lastPage'];
if (!$register)
{echo "Cannot register session variables<br>";}
else {echo "Registered session variables<br>";}
// omitted code that writes to a database
LINK TO FIRST PAGE
-----------------------intro.php---------------------------
<?php
session_start();
$_SESSION['currentPage'] = 0;
/*Checks to make sure that the current page is not farther then the farthest page reached*/
if ($_SESSION['currentPage'] > $_SESSION['lastPage'])
{$_SESSION['currentPage'] = $_SESSION['lastPage'];}
$registered = session_is_registered('firstName');
if ($registered)
{echo "Variables<br>".$_SESSION['firstName']. "<br>"
.$_SESSION['lastName']. "<br>"
.$_SESSION['currentPage']."<br>"
.$_SESSION['lastPage']."<br>";
}
else{echo "Lost the variable";}
?>
/* NOW THIS PRINTS ALL THE RIGHT CONTENTS I.E.
Variables
users firstName
users lastName
currentPage
lastPage */
LINK TO NEXT PAGE
------------------------next.php---------------------------
<?php
session_start();
$_SESSION['currentPage'] = 1;
/*Checks to make sure that the current page is not farther then the farthest page reached*/
if ($_SESSION['currentPage'] > $_SESSION['lastPage'])
{$_SESSION['currentPage'] = $_SESSION['lastPage'];}
$registered = session_is_registered('firstName');
if ($registered)
{echo "Variables<br>".$_SESSION['firstName']. "<br>"
.$_SESSION['lastName']. "<br>"
.$_SESSION['currentPage']."<br>"
.$_SESSION['lastPage']."<br>";
}
else{echo "Lost the variable";}
?>
/* NOW THIS ONLY PRINTS the word "Variables". This tells me that the session is registered, but somehow not visible?*/
Any ideas? Also keep in mind that I am currently just trying to be successfull accessing and passing $_SESSION['variables'] before I actually use them in the site. This is why I want to print out the variables on each page.
-----------------------------LogInProcess.php--------------
/*Processes the login information that is received from the login page */
<?php
session_start();
$register = session_register("firstName", "lastName", "currentPage", "lastPage"
$firstName = $_POST['firstName'];
$lastName = $_POST['lastName'];
$currentPage = $_POST['currentPage'];
$lastPage = $_POST['lastPage'];
if (!$register)
{echo "Cannot register session variables<br>";}
else {echo "Registered session variables<br>";}
// omitted code that writes to a database
LINK TO FIRST PAGE
-----------------------intro.php---------------------------
<?php
session_start();
$_SESSION['currentPage'] = 0;
/*Checks to make sure that the current page is not farther then the farthest page reached*/
if ($_SESSION['currentPage'] > $_SESSION['lastPage'])
{$_SESSION['currentPage'] = $_SESSION['lastPage'];}
$registered = session_is_registered('firstName');
if ($registered)
{echo "Variables<br>".$_SESSION['firstName']. "<br>"
.$_SESSION['lastName']. "<br>"
.$_SESSION['currentPage']."<br>"
.$_SESSION['lastPage']."<br>";
}
else{echo "Lost the variable";}
?>
/* NOW THIS PRINTS ALL THE RIGHT CONTENTS I.E.
Variables
users firstName
users lastName
currentPage
lastPage */
LINK TO NEXT PAGE
------------------------next.php---------------------------
<?php
session_start();
$_SESSION['currentPage'] = 1;
/*Checks to make sure that the current page is not farther then the farthest page reached*/
if ($_SESSION['currentPage'] > $_SESSION['lastPage'])
{$_SESSION['currentPage'] = $_SESSION['lastPage'];}
$registered = session_is_registered('firstName');
if ($registered)
{echo "Variables<br>".$_SESSION['firstName']. "<br>"
.$_SESSION['lastName']. "<br>"
.$_SESSION['currentPage']."<br>"
.$_SESSION['lastPage']."<br>";
}
else{echo "Lost the variable";}
?>
/* NOW THIS ONLY PRINTS the word "Variables". This tells me that the session is registered, but somehow not visible?*/
Any ideas? Also keep in mind that I am currently just trying to be successfull accessing and passing $_SESSION['variables'] before I actually use them in the site. This is why I want to print out the variables on each page.