RE: [PHP] Re: session handling
| From: | Ford, Mike [LSS] | Date: | Mon, 18 Nov 2002 14:22:37 +0000 |
| Subject: | RE: [PHP] Re: session handling | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-124907@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: OrangeHairedBoy [mailto:me@orangehairedboy.com]
> Sent: 16 November 2002 07:23
> To: php-general@lists.php.net
> Subject: [PHP] Re: session handling
>
>
> Here's what you need:
>
> on page 1.php:
>
> <?php
> session_start();
> $temp = 'someValue';
> session_register("temp");
> ?>
>
> on page 2.php:
>
> <?php
> session_start();
> print $temp; /* PHP sets the variables back the way they were
> for you! */
> ?>
>
> You have to register the variable with the session first so
> it knows that
> it's a variable that needs monitored and, when the script
> finishes, needs
> saved.
Actually, Anjali is right on this one, so long as (s)he's using a PHP version that defines the
$_SESSION array; in this case, it's actually recommended to use only the $_SESSION array, and
not use session_register at all.
That said, I can't see anything wrong with the original scripts posted, so the obvious
questions are:
(1) are you sure you're using a recent version that supports the $_* superglobals arrays?
(2) If so, please show how you're reaching 2.php from 1.php.
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS, LS6 3QS, United Kingdom
Email: m.ford@lmu.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211