cforms II, $_SESSION, and passing variables to new pages
-
Hello —
I’m having a problem preserving variables as I move from the form submission page to my success page using cforms II (v 10.2) on WordPress 2.7.
Here’s the deal. I have a form. When the form is submitted, i have a function — very simple — which adds the form variables included in the array $cformsdata to the session variable. I need to use the variables in the page the user is directed to after successful completion of the form. Here’s that function:
function my_cforms_action($cformsdata) { $_SESSION['mbcdata'] = $cformsdata; @mail('[email protected]', 'cforms my_action test', print_r($_SESSION,1), 'From: [email protected]'); }
I’m certain the function is being called — I receive the mail. And $cformsdata is the correct variable. But it’s not working. The value of $_SESSION which I receive in the email is *only* what I assign to it; other session variables that are being passed don’t show up. And, when I’m sent to my success page, the value of the $_SESSION array includes the other session variables that are being passed, but not these new ones including the value of $cformsdata that are being assigned.
In other words, it’s almost like the variable $_SESSION in this function is local to this function and is not the global $_SESSION. And I’m certain sessions are not being wiped out by WordPress, because I have these other session variables hanging around. (They’re from a non-WP script on the same site.)
The strange thing is, this worked for a bit, and I suppose I might have changed something, but I have no idea what I might have changed.
I’ve read through the PHP documentation on session handling, but I haven’t been able to figure out the problem. In particular, I haven’t any idea why $_SESSION doesn’t seem to be getting assigned. Any thoughts?
Thanks in advance.
– geoff
- The topic ‘cforms II, $_SESSION, and passing variables to new pages’ is closed to new replies.