Hi.
I'm working on a project where I need to send a user an e-mail whose content is identical to an already existing PHP-generated web page. (This web page relies on session data to do its work.) The mail function in PHP requires that I save the HTML of this page into a variable and send it along as the third parameter. The simplest way to retrieve the HTML is through a socket connection, correct? The problem I'm suffering from, however, is that when I try to GET a page through a socket, the session information is not retained for the page being retrieved. To correct this, I try sending along ?session_name()=session_id() after the name of the page in the GET header. However, doing this causes the browser to hang indefinitely.
Here's the code I've been working with.
$fp = fsockopen (" 80, $errno, $errstr);
fputs ($fp, "GET /itemizeFoods.php?" . session_name() . "=" . session_id() . " HTTP/1.0\n\n"
while (! feof ($fp)) {
$message .= fgets ($fp, 128);
}
mail ($target_email,
'Food Reports',
$message,
"From: $source_email\n"
. "Reply-To: $source_email\n"
. 'X-Mailer: PHP/' . phpversion() . "\n"
. "Content-type: text/html; charset=iso-8859-1\n" );
I've also tried just passing the query string as ?id=session_id() (not PHPSESSID=session_id() and including at the top of the the PHP-generated page the following.
session_id($id);
session_start();
This also causes the browser to hang.
If I open a new browser and manually type itemizeFoods.php?PHPSESSID=396 (or whatever the ID happens to be of my current session) or link to itemizeFoods.php?396 the session continues just fine. The page loads properly and session variable values are consistent. It's only when I try to retrieve a page through a socket that the problem arises.
Others have referred me to the curl library, but the installation of PHP I have to work with was not compiled with curl and can't be changed.
If you have any ideas as to how I might fix or circumvent my problem, please let me know.
--
Chris Johnson
I'm working on a project where I need to send a user an e-mail whose content is identical to an already existing PHP-generated web page. (This web page relies on session data to do its work.) The mail function in PHP requires that I save the HTML of this page into a variable and send it along as the third parameter. The simplest way to retrieve the HTML is through a socket connection, correct? The problem I'm suffering from, however, is that when I try to GET a page through a socket, the session information is not retained for the page being retrieved. To correct this, I try sending along ?session_name()=session_id() after the name of the page in the GET header. However, doing this causes the browser to hang indefinitely.
Here's the code I've been working with.
$fp = fsockopen (" 80, $errno, $errstr);
fputs ($fp, "GET /itemizeFoods.php?" . session_name() . "=" . session_id() . " HTTP/1.0\n\n"
while (! feof ($fp)) {
$message .= fgets ($fp, 128);
}
mail ($target_email,
'Food Reports',
$message,
"From: $source_email\n"
. "Reply-To: $source_email\n"
. 'X-Mailer: PHP/' . phpversion() . "\n"
. "Content-type: text/html; charset=iso-8859-1\n" );
I've also tried just passing the query string as ?id=session_id() (not PHPSESSID=session_id() and including at the top of the the PHP-generated page the following.
session_id($id);
session_start();
This also causes the browser to hang.
If I open a new browser and manually type itemizeFoods.php?PHPSESSID=396 (or whatever the ID happens to be of my current session) or link to itemizeFoods.php?396 the session continues just fine. The page loads properly and session variable values are consistent. It's only when I try to retrieve a page through a socket that the problem arises.
Others have referred me to the curl library, but the installation of PHP I have to work with was not compiled with curl and can't be changed.
If you have any ideas as to how I might fix or circumvent my problem, please let me know.
--
Chris Johnson