Posted by Matthew Weier O'Phinney on 03/31/05 15:09
* Rosen <r.marinov@gmail.com>:
> Hi,
> I have this code :
>
> ========
> page1.php:
> <?
>
> $nfo["fu"]="12";
>
> session_start();
> session_register(nfo);
As of PHP 4.1.0, you no longer need to use session_register(); you can
simply add items to the $_SESSION superglobal array:
$_SESSION['nfo'] = $nfo;
Visit http://php.net/session for more information.
> $sn=session_name();
> $nn=session_id() ;
>
> $web="page2.php?lang=en";
> $web.="&$sn=$nn";
>
> header("Location: $web");
> ?>
> ===============
> page2.php:
> <?
> session_start();
> global $nfo;
This only works if you have register_globals on -- which you probably
shouldn't. A better, more portable way to do this would be:
$nfo = array();
if (isset($_SESSION['nfo'])) {
$nfo = $_SESSION['nfo']
}
> $uss=$nfo["fu"];
>
> echo $uss; //// HERE $uss is empty!
You should probably check for the existence of the 'fu' key in the array
before doing this.
$uss = null;
if (isset($nfo['fu'])) {
$uss = $nfo['fu'];
}
if (empty($uss)) {
echo "Missing vital session info";
die;
}
echo $uss;
> This script works on several linux servers, but on one doesn't work (
> variable $uss in page2.php has no value ).
> I think this may be problem with PHP configuration on this server ( I don't
> have root password for this server ).
I've pointed out my recommendations above.
--
Matthew Weier O'Phinney | WEBSITES:
Webmaster and IT Specialist | http://www.garden.org
National Gardening Association | http://www.kidsgardening.com
802-863-5251 x156 | http://nationalgardenmonth.org
mailto:matthew@garden.org | http://vermontbotanical.org
[Back to original message]
|