Jump to content

Archived

This topic is now archived and is closed to further replies.

Spreegem

Sessioning an array?

Recommended Posts

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?

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

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

Share this post


Link to post
Share on other sites
That looks ok, except you really don't need the double quotes in this line:[code]<?php $h_class = $class_array["$num"]; ?>[/code]

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

Ken

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.