Hello there,

I figured out how to pass single variables through sessions by using the session_start() call, I have been trying to pass variables that are arrays without any sucess.

here is the code that i ihave

<? session_start();
$PassingArray[0] = 1;
$PassingArray[1] = 2;
$PassingArray[2] = 3;

$_SESSION['array'] = $passingarray;
?>

And when i go to page two , I am using the following Code and nothing outputs

<?
session_start();
foreach ($_SESSION['array'] as $key => $value) {
echo "test";
}
echo "<br>";
?>

Can someone help point me in the right direction? thanks. I appreciate it.

    Check your variable names, $passingarray is NOT the same as $PassingArray.

      Also do your self a favor and make a habit of writing php using <?php instead of <? or a 'short tag' which might not work if you were to move to another server and use the little ~ (tilde) sign that is within what looks like a dogeared page when you enter PHP code, this looks better and make spotting syntax errors in your code much easier plus it take less page area. after pasting your code into your post simply highlight it by dragging your mouse and then clicking the ~

        Write a Reply...