RE: [PHP] Session variable under PHP 4.0.6
| From: | Johnson, Kirk | Date: | Mon, 03 Mar 2003 16:41:54 +0000 |
| Subject: | RE: [PHP] Session variable under PHP 4.0.6 | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-137915@lists.php.net to get a copy of this message | ||
In the first file, replace this line:
$HTTP_SESSION_VARS['variable']="the variables value";
with these two lines:
$variable = "the variables value";
session_register('variable');
This is because 'register_globals' is enabled in the php.ini file.
Kirk
> -----Original Message-----
> From: Henry Grech-Cini [mailto:henry@teacake.force9.co.uk]
> Sent: Monday, March 03, 2003 9:34 AM
> To: php-general@lists.php.net
> Subject: [PHP] Session variable under PHP 4.0.6
>
>
> Hi All,
>
> I'm having a problem with session variables under PHP 4.0.6
> on a secure
> server. I ran phpinfo and have attached the resulting page
> after the main
> body of this message.
>
> My test code looks like this
>
> Filename: index.php
>
> Page Start --------------
>
> <?php
> session_start();
>
> $HTTP_SESSION_VARS['variable']="the variables value";
>
> ?>
> <a href="index2.php">click here</a> to go to the next page
>
> Page End ------
>
>
> Next file
> Filename: index2.php
>
> Page Start --------------
>
> <?php
> session_start();
>
> print_r($HTTP_SESSION_VARS);
>
> echo "-->".$HTTP_SESSION_VARS['variable']."<--";
> ?>
>
> Page End ------
>
>
> Suffice to say it doesn't work. The first page displays
>
> "click here to go to the next page"
>
>
> as expected. However clicking on the link takes you to
> index2.php and the
> following is displayed:
>
>
> "Array ( ) --><--"
>
>
> Namely that the session variable called "variable" is not set in the
> session.
>
>
> I have run the exact same code on a machine running PHP 4.2.3
> (non secure
> servers) and it works perfectly! And outputs:
>
> "Array ( [variable] => the variables value ) -->the variables
> value<--"