benphp Posted January 12, 2011 Share Posted January 12, 2011 I haven't used sessions much until now, so this is probably due to my ignorance. I have a page that sets the session variable, and if I print from that page, the session variable (an array) is correct. But when I move to the next page, the same session variable has old, old, wrong data. The $arrAttendeeList is an exploded list from a textarea on a form turned into an array. Example: This page, let's call it page1.php, sets the variable: <?php $_SESSION['arrAttendeeList'] = $arrAttendeeList; foreach ($_SESSION['arrAttendeeList'] as $temp) { print "$temp <br />"; } exit; ?> Results: Smithers, Waylon Bouvier, Selma Brockman, Kent But the next page, page2.php, when I call the same variable: <?php foreach ($_SESSION['arrAttendeeList'] as $temp) { print "<br />$temp <br>"; } ?> I get yesterday's data: Smithers, Waylon Bouvier, Selma I've tried setting the session var to null but with the same results. Do I need to kill the session var before setting it to something else? Thanks - Quote Link to comment Share on other sites More sharing options...
litebearer Posted January 12, 2011 Share Posted January 12, 2011 are you starting sessions at the top of your pages? Quote Link to comment Share on other sites More sharing options...
benphp Posted January 12, 2011 Author Share Posted January 12, 2011 Yep. session_start(); Quote Link to comment Share on other sites More sharing options...
benphp Posted January 12, 2011 Author Share Posted January 12, 2011 litebearer - actually, you made me think about it, and NO - so you solved it for me. THANKS! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.