I have a function that accepts $_POST data from a form, and uses it to generate a session containing the relevant data. At the beginning of the script, $_SESSION is empty. At the end of the script, the $_POST and $_SESSION arrays contain the following:
post
Array ( [username] => myusername [password] => mypassword [login_temp] => not_public_terminal [submit] => Login [signin_submitted] => TRUE [teacher_id] => 5227 [active] => a00b109d99b0f0d3642b0f3f60
99e678 [invitee_email] => myemail@gmail.com )
session
Array ( [user_id] => 1 [name] => MyName [username] => myusername [active] => [email] => myemail@gmail.com )
The active variable in the post array is a 32-char string. The active variable in the second array is NULL.
If I then navigate to another page on my site and print out the session variables after starting the session, I get
post
Array ( )
session
Array ( [user_id] => 1 [name] => MyName [username] => myusernmae [active] => a00b109d99b0f0d3642b0f3f60
99e678 [email] => myemail@gmail.com )
thus, the active variable is for some reason the 32-character string from the $_POST array, and not the NULL value from the $_SESSION array.
Now if, instead of setting active to NULL, I set it to some other value, say 'not null', the above phenomenon does not occur. If I then navigate to another page, $_SESSION['active'] == 'not null', rather than the value of $_POST['active'] from the preceding page.
One other thing I noticed: if I am already signed in (as any user), and then sign into an account using the script in question, I do not see this issue. $_SESSION['active'] remains NULL, and does not magically switch to the value of $_POST['active'] when I navigate to the next page. It is only when I start from being signed out that I see this problem.
Any suggestions regarding what might be causing this behavior would be greatly appreciated. I realize that I can just change the name of the $_POST['active'] variable, but I would like to know what is going on, not just work around it.