PHP http include not saving sessions
Basically I hate a satellite website that is including form.php from an entirely different server.
<?php
include("http://blah.com/form.php");
?>
The form.php on the other sessions loads classes and all kinds of other things and generates a form dynamically based on a ton of MySQL data. Unimportant. My issue is that when the form is called I also start a session. Yet the remote server is not actually ever visited by the client. The session what stay. Every time the page is refreshed the old session is being dumped.
The whole reason for this is I need to send back validation errors to the original form and have them display. (It's an array of things like "First name is a required field")
The code on the main server looks something like this...
<?php
include("config.php"); // This is loading the config file with the session_start()
Process($id) {
// Do a bunch of form processing and store errors in $this->errors
$_SESSION['errors'] = $this->errors;
}
ShowForm($id) {
// This loads the form and everything.
开发者_运维技巧 echo '<div id="errors">'.print_r($_SESSION['errors']).'</div>'; // This is what is returning nothing on the other page.
}
?>
So basically that script is called from the remote site, but the sessions won't save and are dumped on refresh... I assume its because the actualy main server is never loaded in the users browser.
Does anyone know a way around this/a way to fix this? Or possibly a different solution? Anything works.
Thanks
that's indeed terrible design.
include("http://blah.com/form.php?var=1&error=First%20name%20is%20a%20required%20field");
you have to think of XMLRPC or some other civilized way of data interchange
精彩评论