Posted by Jerry Stuckle on 08/13/07 03:00
garks wrote:
> I am the newbie in php
> I have a problem about the session variable
> When I create the session and session variable,
> the variable is set in page 1, but in page 2 the variable is unset
> and I don't know why.
> I have searched a lot of tutorial, I followed all the steps but still
> not work
> Can anybody help me!!~
> Thank you in advanced
>
>
> I have created following code
> page1.php:
>
> <?php
> session_start();
> $_SESSION["test"] = "hello";
> echo $_SESSION['test'];
> header("Location: page2.php");
> ?>
>
> page2.php
>
> <?php
> session_start();
> if( !isset($_SESSION['test'])){
> echo "The variable is not set
> }
> ?>
>
> The output:
> page 1: hello
> page 2: The variable is not set
>
Turn on all errors and enable error reporting to the display.
It's best to do it in the php.ini file. However, you can also add these
to your code as the first things in the file:
error_reporting(E_ALL);
ini_set('display_errors', '1');
That should help you find your problem.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
[Back to original message]
|