3

I got the following:

$_SESSION["content"] = $contentList->Value;

Where it assigns an array of objects to the session variable... When I then try to access the array it return 60 elements for example that are the size of the array but the objects in the array are blank... None of the properties in them are set.

Try to access:

$contentList = $_SESSION["content"];
foreach($contentList as $currentContent)
{
    //......
}
6
  • 2
    Are you sure you're assigning what you think to $_SESSION['content'] ? if you use var_dump($_SESSION['content']) after the assigning the value, does the ouput look correct ? Commented Mar 19, 2011 at 21:46
  • 1
    You should serialize the array before storing it in a session. Commented Mar 19, 2011 at 21:47
  • Outlook doesn't look correct. I also have serialize and then unserialize the object in this case it only remember 1 out of the 5 properties, doesn't remember the others... Weird Commented Mar 19, 2011 at 22:01
  • 3
    PHP's session stuff will serialize the whole session before storing it, and arrays within it will be serialized correctly without doing anything. Serializing your own stuff would be more busywork than any real fix for anything. Commented Mar 19, 2011 at 22:02
  • Please provide more information, it's hard to help if you don't let us know what you've tried and tested so far. Commented Mar 19, 2011 at 22:15

1 Answer 1

2

Make sure you have included the classe definition before invoking sesssion_start()

Sign up to request clarification or add additional context in comments.

1 Comment

Yes am sure that it gets included before session_start()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.