I've got a perfectly functioning site which uses sessions. The only exception, is one particular page. The page performs some DB SELECTS, verification stuff, etc. etc. Then, later on, in the HTML part, ive got a tag. Between that, ive got
<?php
$classes = explode(",", $_SESSION['classes']);
foreach ($classes as $class) {
echo "<option>".$class."</option>";
}
?>
Now $_SESSION['classes'] is a comma separated string. Example: "10 A,11 D,12 C"
here's the weird part, when i load this page, everything works perfectly, and i get a drop-down select with options 10 A, 11 D and 12 C... but, when i refresh the page, I get a dropdown box with only one option: Array
Yes, it just says Array.... no other options.
And no, i haven't set the value to anything else after that PHP block. in fact, i dont have another PHP block after this one
To debug it, I added a php block with the code: echo $_SESSION['classes'];
after the </select>
tag, and the first page load, it said 10 A,11 D,12 C
. After refresh, it said Array
Then i tried var_dump($_SESSION);
and it said ["classes"]=> &string(9) "11 A,10 C"
Heres the weirdest part: After refresh, it said ["classes"]=> &array(2) { [0]=> string(4) "11 A" [1]=> string(4) "10 C" }
and on another refresh, it said ["classes"]=> &array(1) { [0]=> string(5) "Array" }
This only happens on my web host though, not on my local server. And, only on this page
I have no idea what's causing this, or how to fix it