On 4 Apr 2004 Randall Perry wrote:

> Solved my main problem. I was assuming that variables registered with
> $_SESSION were passed by reference. Apparently they're passed by value.

*Passing* by value or by reference has to do with function parameters, 
not array values.  However you can assign one variable as a reference 
to another, see http://www.php.net/manual/en/language.references.php.

When you enter a line of code like:

        $_SESSION['order'] = $order;

you are doing a regular assignment.  To use a reference instead, use:

        $_SESSION['order'] =& $order;

The data will be passed this way to the next session.  For example, try 
this (substitute your server name in the header() call):

test1.php:

<?php
session_start();
$test1 = "";
$_SESSION["Test1"] =& $test1;
$test1 = "this is test1";
header("Location: http://localhost/olm/test2.php";);
?>

test2.php:

<?php
session_start();
var_dump($_SESSION);
?>

The output on the second page will be something like this (I'm using 
xdebug so this is not raw var_dump() output):

array
  'Test1' => 'this is test1'

--
Tom

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to