It's much easier and works better to use:
<?php
session_start();
$_SESSION['sess_var'] = "Hello World!";
//then you can echo
echo "The content of \$_SESSION['sess_var'] is " . $_SESSION['sess_var']
. "<br>";
?>
<a href="session2.php">Next Page</a>
?>
That will set everything and echo correctly... this also makes it more
obvious for later where your variables are coming from.
On Thu, 2003-03-27 at 08:03, Tiago Simões wrote:
> Hi,
>
> I am using PHP version 4.3.0, Apache 2.0.44 on Windows XP. I am new to
> Sessions and need your help with the problem below...
>
> I've done this simple session test:
>
> on session1.php:
>
> <?
> session_start();
> session_register("sess_var");
>
> $sess_var = "Hello World!";
>
> echo "The content of \$sess_var is $sess_var<br>";
>
> ?>
> <a href="session2.php">Next Page</a>
>
> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
> . . . . . . . . . . . . . . . .
>
> on session2.php:
>
> <?
> session_start();
> echo "The content of \$sess_var is $sess_var<br>";
>
> ?>
>
> When i test this, on the session2.php file, i get this error:
>
> Notice: Undefined variable: sess_var in C:\Program Files\Apache
> Group\Apache2\htdocs\sites\activa\homepage\session2.php on line 3
>
> It's strange, because it writes a session file to my temporary folder
> (session.save_path = c:/tmp).I've tried everything (even enabling
> session.use_trans_sid)...
>
> Any thoughts?
> Thank you in advance...
>
> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
> . . . . . . . . . . . . . . . .
>
>
> This is my configuration in PHP.ini (global variables off)
>
> session.save_handler = files
> session.save_path = c:/tmp
> session.use_cookies = 1
> session.name = PHPSESSID
> session.auto_start = 0
> session.cookie_lifetime = 0
> session.cookie_path = /
> session.cookie_domain =
> session.serialize_handler = php
> session.gc_probability = 1
> session.gc_maxlifetime = 1440
> session.referer_check =
> session.entropy_length = 0
> session.entropy_file =
> session.cache_limiter = nocache
> session.cache_expire = 180
> session.use_trans_sid = 0
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php