mssing session variable in other page

mssing session variable in other page

am 13.08.2007 04:56:20 von garks

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:

session_start();
$_SESSION["test"] = "hello";
echo $_SESSION['test'];
header("Location: page2.php");
?>

page2.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

Re: mssing session variable in other page

am 13.08.2007 05:00:17 von Jerry Stuckle

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:
>
> > session_start();
> $_SESSION["test"] = "hello";
> echo $_SESSION['test'];
> header("Location: page2.php");
> ?>
>
> page2.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
==================

Re: mssing session variable in other page

am 13.08.2007 05:18:02 von garks

Thanks for your help~
The following warnings are shown~
How do I correct them?
I don't know how to start the correction
Thank you in advanced.

Warning: session_start() [function.session-start]: open(/var/lib/php/
session/sess_9q770lvt0o29f7h8kb81ng97k5, O_RDWR) failed: Permission
denied (13) in /usr/local/apache2/htdocs/page2.php on line 4
The variable is not set
Warning: Unknown: open(/var/lib/php/session/
sess_9q770lvt0o29f7h8kb81ng97k5, O_RDWR) failed: Permission denied
(13) in Unknown on line 0

Warning: Unknown: Failed to write session data (files). Please verify
that the current setting of session.save_path is correct (/var/lib/php/
session) in Unknown on line 0

Re: mssing session variable in other page

am 13.08.2007 05:27:26 von garks

/var/lib/php/session <- is valid path

I have checked the files in this path
It seems that the sess_9q770lvt0o29f7h8kb81ng97k5 has not been created
in the /var/lib/php/session

Re: mssing session variable in other page

am 13.08.2007 05:29:42 von Jerry Stuckle

garks wrote:
> /var/lib/php/session <- is valid path
>
> I have checked the files in this path
> It seems that the sess_9q770lvt0o29f7h8kb81ng97k5 has not been created
> in the /var/lib/php/session
>
>

It means the userid Apache is running under doesn't have permission to
access this directory.

However, session information is generally stored in /tmp. I'd suggest
you use it.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: mssing session variable in other page

am 13.08.2007 05:37:21 von garks

It works after I changed the session_save_path to /tmp

Thank you for your help~