PHP Sessions, help needed.
Posted: Sun Jun 11, 2006 4:28 am
Hi,
I've been learning HTML/PHP and MySQL over the past three days and have come unstuck on sessions under PHP.
My exact problem is that I receive an error that the "_SESSION" variable is undefined (I'm attempting to implement a login-system for my locally hosted website.)
It seems that the _SESSION variable is only available within the scope of a single PHP script, that or, cookies are not working as they should. For example, take the following two files;
Page1.php
Page2.php
The first script will execute no problem, no errors, but when it comes to the second I will receive the 'undefined _SESSION' error.
Maybe someone could shed some light on my problem? Thanks in advance.
P.S. I'm running an Apache 2.0 webserver and PHP 5.1.4
-Matt
I've been learning HTML/PHP and MySQL over the past three days and have come unstuck on sessions under PHP.
My exact problem is that I receive an error that the "_SESSION" variable is undefined (I'm attempting to implement a login-system for my locally hosted website.)
It seems that the _SESSION variable is only available within the scope of a single PHP script, that or, cookies are not working as they should. For example, take the following two files;
Page1.php
Code: Select all
<SCRIPT language="php">
session_start();
$_SESSION["Username"] = "Win32";
</SCRIPT>Code: Select all
<SCRIPT language="php">
print($_SESSION["Username"]);
</SCRIPT>Maybe someone could shed some light on my problem? Thanks in advance.
P.S. I'm running an Apache 2.0 webserver and PHP 5.1.4
-Matt