Jump to content


Sessioning an array?

  • Please log in to reply
2 replies to this topic

#1 Spreegem

  • Members
  • Pip
  • Newbie
  • 4 posts

Posted 14 June 2006 - 09:49 PM

I am trying to sesssion an array, and then get some data from the array after some form data is submitted to another page, but when I try and get data from it, the array is blank. Is it even possible to session arrays, or am I doing something wrong in my code?

//From page 1
$_SESSION['h_class'] = $class_array;

//From Page 2
$class_array = $_SESSION['h_class']; 
$h_class = $class_array["$num"];

#2 kenrbnsn

  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 14 June 2006 - 09:56 PM

That looks ok, except you really don't need the double quotes in this line:
<?php $h_class = $class_array["$num"]; ?>

Do you have a "session_start()" line at the start of each script?
If you put the line
<?php echo '<pre>' . print_r($_SESSION,true) . '</pre>'; ?>
right after the sessions_start(), what displays?


#3 Spreegem

  • Members
  • Pip
  • Newbie
  • 4 posts

Posted 15 June 2006 - 12:46 AM

Thanks a bunch, but it was actually working from the beginning, its just where I was trying to use it the if was incorrect and so I didnt think it was working even though it was. Thank you for your help!

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users