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 and send
along with it ?session_name()=session_id(), the browser hangs for an
indeterminate amount of time.
Here's the code I've been working with.
$fp = fsockopen ("www.example.com", 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();
That 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 problems arises.
Others have referred me to the curl library, but the installation of PHP
I have to work with was not compiled with curl.
If you have any ideas as to how I might fix of circumvent my problem,
please let me know.
--
Chris Johnson
Dyton Media, Inc.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
- [PHP] Continuing Session Within Socket Chris Johnson
- Chris Johnson