Session variable as array lost between pages - Solved
Posted: Fri Sep 14, 2007 1:35 pm
scottayy | Please use
The second page just has this and a similar link back to the first page.
scottayy | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hello.
Can someone please tell me why all my session variables are passed from one page to another successfully except those which have been assigned an array?
I've now reduced the code to the simplest and it still doesn't work! This page outputs the array successfully, but the second page doesn't
I'm testing on a remote server which has register_globals on (if that's relevant).
Thanks a lot.Code: Select all
<?php session_start();
$_Session['mpl'] = array();
$_Session['mpl'][0] = 'hello';
print_r($_Session['mpl']);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<a href="http://www.mydomain.com/session_array_test_2.php" class="bold">Go To session_array_test_2</a>
</body>
</html>Code: Select all
<?php session_start();
if (!isset($_SESSION['mpl'])) {echo 'Variable not set! ';}
else { print_r($_Session['mpl']); }
?>scottayy | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]