Hi. I'm working on a script that will e-mail the user the PHP-generated HTML for several web pages. These PHP-generated pages rely on some session variables to get their jobs done, so I need to have these pages inherit the session information from the script that's loading them.
I'm not displaying these pages in the browser, only retrieving their HTML content to pass along in an e-mail message. So, I must use sockets to get the processed pages and save them into a variable. But pages retrieved via sockets in the conventional way appear not to have any idea about the session they're in. They create new session information.
So I figured need to send along the session name and session id. I've tried using GET and POST to send along a query string, but that's failing to get the job done. The code below is my attempt thus far.
$message = "";
$sid = session_name() . "=" . session_id();
$headers = "POST /$get_page HTTP/1.1\n"
. "Host: $server\n"
. "User-Agent: PHP/" . phpversion() . "\n"
. "Content-Type: application/x-www-form-urlencoded\n"
. "Content-Length: " . strlen ($sid) . "\n\n"
. "$sid\n";
$socket = fsockopen ($server, 80, $errno, $errstr);
fputs ($socket, $headers);
while (! feof ($socket)) {
$message .= fgets ($socket , 128);
}
fclose ($socket);
mail ($sendee_address,
$subject,
$message,
"From: <$sender_address>\n"
. "Reply-To: $sender_address\n"
. 'X-Mailer: PHP/' . phpversion() . "\n"
. "Content-type: text/html; charset=iso-8859-1\n' );
If anyone has any idea how I can restore sessions (without storing the session in a file) in files generated by sockets, I could sure use some help. Thanks.
--
Chris Johnson
Dyton Media, Inc.