Skip to content
Advertisement

PHP passing array in session variable

I am trying to get an array to pass in a session variable from one page to another. I am setting the session variable equal to my the $_POST data collected from my form. Printing the variable for test shows me that it is getting set initially on Page 1.

Page 1

JavaScript

On Page 2 I am trying to set it equal to another variable. Again I test to see if the array has passed to page 2 but it doesn’t and I get an error for not having a valid array for the array_sum function

session_start(); // start up your PHP session!

JavaScript

Any help would be greatly appreciated.

Advertisement

Answer

You’re setting $_SESSION['userdata'] to the value of $userqty, which is uninitialized.

Change your first line to:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement