tcorbeil Posted April 16, 2007 Share Posted April 16, 2007 Is there a maximum amount of variables you can stack into a session array? I have this: $_SESSION['count'] = $first; $_SESSION['blah'] = $first; echo $_SESSION['blah']."--"; echo $_SESSION['count']; the result is always the same, $_SESSION['count'] = $first; seems to take but the second does not.. I do have several other session values.. just wondering if I reched my limit?? I have tried everything I could think of but no go.. T. Link to comment https://forums.phpfreaks.com/topic/47235-_session-question/ Share on other sites More sharing options...
tcorbeil Posted April 16, 2007 Author Share Posted April 16, 2007 ok, in testing, I had this line before any of the code above.. $_SESSION['1'] = "test"; it appears that a session aray cannot be numbers?? T Link to comment https://forums.phpfreaks.com/topic/47235-_session-question/#findComment-230362 Share on other sites More sharing options...
kenrbnsn Posted April 16, 2007 Share Posted April 16, 2007 Do you have "session_start()" at the beginning of your code? Ken Link to comment https://forums.phpfreaks.com/topic/47235-_session-question/#findComment-230366 Share on other sites More sharing options...
suzzane2020 Posted April 16, 2007 Share Posted April 16, 2007 yes it cannot be. had the same issue before it does'nt recognize those sessions Link to comment https://forums.phpfreaks.com/topic/47235-_session-question/#findComment-230367 Share on other sites More sharing options...
trq Posted April 16, 2007 Share Posted April 16, 2007 '1' is a string because of the quotes, but yes, you are correct. the $_SESSION array is associative. What exactly is the problem? Link to comment https://forums.phpfreaks.com/topic/47235-_session-question/#findComment-230371 Share on other sites More sharing options...
tcorbeil Posted April 16, 2007 Author Share Posted April 16, 2007 well here goes: yes i do have the Session start.. I was trying to use a counter to load a session array.. while ($i < $num) { ..some code assigning a value to $first... $_SESSION[$i] = $first; $_SESSION['blah'] = $first; // for troubleshooting I added a this line.. $_SESSION['count2'] = $i; echo $_SESSION['blah']."--"; echo $_SESSION['count2']; } on echo, $_SESSION['count2'] = $i; always took so i rem'd out the $_SESSION[$i] = $first; line and it seemed to work.. of course, $i being a counter, I guess this is not acceptable.. Any ways around this? I can't use a hardwired string to load the session array as the values will change all the time.. Link to comment https://forums.phpfreaks.com/topic/47235-_session-question/#findComment-230386 Share on other sites More sharing options...
kenrbnsn Posted April 16, 2007 Share Posted April 16, 2007 You can change <?php $_SESSION[$i] = $first; ?> to <?php $_SESSION['x'.$i] = $first; ?> which makes the index a string. Ken Link to comment https://forums.phpfreaks.com/topic/47235-_session-question/#findComment-230397 Share on other sites More sharing options...
tcorbeil Posted April 16, 2007 Author Share Posted April 16, 2007 kenrbnsm, that is brilliant! -Thank you! T. Link to comment https://forums.phpfreaks.com/topic/47235-_session-question/#findComment-230410 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.