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. Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment 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? Quote Link to comment 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.. Quote Link to comment 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 Quote Link to comment 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. 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.