Page 1 of 1

save array as a session?

Posted: Mon Sep 17, 2007 5:03 pm
by lafflin
hello, I am trying to store several input values into an array as a session. here is the code i have used:

Code: Select all

$student_info= array($fn, $ln, $dob, $sex, $school, $medical, $notes) ;
			   $_SESSION['stud_info']=$student_info   ;
it works and the var_dump
looks like this:
array(7) { [0]=> string(6) "pierre" [1]=> string(7) "hobstra" [2]=> string(8) "20030809" [3]=> string(1) "m" [4]=> string(4) "null" [5]=> string(32) "these are all my medical issues." [6]=> string(70) "blah blah blah blah blah blah blah....that\'s all she ever says to me." }
which seems to be good to me, I don't know why there is curly braces, but I have never tried this before either. I'm just learning.

then I try to call the one of the values like this:

Code: Select all

var_dump ($_SESSION['stud_info[1]']);

it doesn't work, I get NULL.

can anyone tell me what I'm doing wrong? what would be the best way to do this?

Thanks.

Posted: Mon Sep 17, 2007 5:06 pm
by volka
var_dump ($_SESSION['stud_info'][1]);

Posted: Mon Sep 17, 2007 5:31 pm
by lafflin
vielen Dank

Posted: Mon Sep 17, 2007 5:33 pm
by Luke
let me know if when you do that it outputs "The Ninja Space Goat" (super stud)

(sorry I couldn't help myself... I'm a stud :lol: )