Page 1 of 1

Very newbie question about session variables

Posted: Thu Jul 04, 2002 9:26 am
by noguru
Hi all,

I can't get my other pages to read session variables set on one page.

I'm using PHP Version 4.0.4. I have tried $HTTP_SESSION_VARS but found $_SESSION to work as well with this version.

Here's the code for page1.php:

<?php
session_start();
$_SESSION['uid']=24;
echo $_SESSION['uid'];
?>


and for page2.php:

<?php
session_start();
echo $_SESSION['uid'];
?>


On page1.php it echos the value of the Session variable, but on any other page it does not. I know I'm missing something, my code seems just too easy.

Any help is appreciated!

Thanks

Posted: Thu Jul 04, 2002 9:34 am
by twigletmac
$_SESSION isn't working as it would in v4.1 up - you are simply creating an array called $_SESSION which is not special in any way. You need to use $HTTP_SESSION_VARS instead. Also look at the session_register() function.

Mac

Posted: Thu Jul 04, 2002 10:11 am
by noguru
thanx a lot twiggie! it's working (finally)!!! may your brain never rotten and your generosity never be forgotten! :roll: