can't pass variable with $_SESSION
Posted: Wed Jan 05, 2011 1:36 am
Hi all,
I have a very simple form, where the user just has to press a button several times. Each time a php script is called, which generates a random number and makes some calculations. So, I need to keep a count of how many times the user has pressed the button. I tried to use superglobal $_SESSION['...'] for that, but somehow that does not work. After pressing the button, when the script is called again, the variable appears to be not set.
Before, I used this approach successfully on pages that require user login. But this page does not require a user to login. So, I thought that this could be the reason because no session was created. Then I created a session explicitly using session_start() function. But even then I got the same result - when the script is called the second time the variable $_SESSION['...'] is not set, so no variable is passed to the second instance of the script.
Can anybody help with this?
I have a very simple form, where the user just has to press a button several times. Each time a php script is called, which generates a random number and makes some calculations. So, I need to keep a count of how many times the user has pressed the button. I tried to use superglobal $_SESSION['...'] for that, but somehow that does not work. After pressing the button, when the script is called again, the variable appears to be not set.
Before, I used this approach successfully on pages that require user login. But this page does not require a user to login. So, I thought that this could be the reason because no session was created. Then I created a session explicitly using session_start() function. But even then I got the same result - when the script is called the second time the variable $_SESSION['...'] is not set, so no variable is passed to the second instance of the script.
Can anybody help with this?