fsockopen y session_start

From: Date: Mon, 07 Mar 2005 14:51:54 +0000
Subject: fsockopen y session_start
Groups: php.general.es 
Request: Send a blank email to general-es+get-53559@lists.php.net to get a copy of this message
*This message was transferred with a trial version of CommuniGate(tm) Pro* Hola, Estoy usando fsockopen para simular un POST a otra página (test_post.php) dentro del mismo sevidor. Los datos que envío por el sockect son: "POST $uri HTTP/1.1\r\n". "Host: $host\n". "User-Agent: mandapost\r\n". "Cookie: ".session_name()."=". session_id()."\r\n". "Content-Type: application/x-www-form-urlencoded\r\n". "Content-Length: $contentlength\r\n". "Connection: close\r\n\r\n". "$my_post_variables\r\n"; Uso $_SESSION para almacenar algunas variables. El fichero test_post.php es: <?php session_start(); echo "User".$_SESSION["user"]; .. El problema es que session_start me inicia una nueva sesión, en lugar de usar el session_id que le mando en la cookie. En el manual online de PHP un usuario comentó: "Just for info, session_start() blocks if another PHP using the same session is still running in background. It seems it's waiting the other PHP to finish... and sometimes it can be a problem. Create 2 different sessions by setting 2 different names : session_name() solve the problem." Estaba en lo cierto, y PHP se cuelga durante un tiempo hasta que algún time-out o algo ocurre. En cualquier caso, la sessión anterior no se abre. He probado a cambiar el nombre con session_name, a cambiar la ID con session_regenerate_id, también he hecho pruebas con session_id(), ... Este es el código actual: <?php $previous_name = session_name("MASIVO"); //sessionid($previous_name); session_start(); //session_regenerate_id(); echo "##".$previous_name."##".$_COOKIE[$previous_name]."##"; // (1) echo "User".$_SESSION["user"]; (1) Es correcto: ##PHPSESSID##09a169b69eccbf2dd49407c5d4cc84aa## Y esto es loque me devuelve el socket: HTTP/1.1 200 OK Date: Mon, 07 Mar 2005 13:43:51 GMT Server: Apache/1.3.28 (Unix) PHP/4.3.3 mod_ssl/2.8.15 OpenSSL/0.9.7c X-Powered-By: PHP/4.3.3 Set-Cookie: MASIVO=79241c1fb5309b6487f689eb30c65caa; path=/ Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: private, max-age=10800, pre-check=10800 Last-Modified: Mon, 7 Mar 2005 13:38:57 GMT Connection: close Transfer-Encoding: chunked Content-Type: text/html c7 ##PHPSESSID##09a169b69eccbf2dd49407c5d4cc84aa## Notice: Undefined index: user in ... etzetera Observad que en la cookie MASIVO me manda el ID de la nueva sessión. Me quedo sin ideas. ¿ Alguien puede ayudar ? Gracias. Pedro.

« previous php.general.es (#53559) next »