You can do:
session_start();
$session_id = session_id();
session_write_close();

Lock has been released, now you are free to post $session_id to the other script

N. F. Singh wrote:

Good point. However, the whole point is that I need to pass that session ID
so that TST2 can access the same session info TST1 is. Know what I mean? I
wonder how I can resolve this...

Thanks for the reply!

----- Original Message -----
From: "Marek Kilimajer" <[EMAIL PROTECTED]>
To: "Nicholas F. Singh" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Thursday, May 29, 2003 11:11 AM
Subject: Re: [PHP] [sessions] using [sockets]. Very tough!




Nicholas F. Singh wrote:



Hello all you great PHPers,

Who among you can solve this tricky problem?

OK, a little background: my goal is to send local POST requests to some


of my php pages from **within** a php program. I have already successfully
done simple POST data transfers with sockets using "HTTPClient.class". This
is not an issue. This class really just prints out the appropriate headers
and receives a server response using sockets -- rather simple.


I am now trying to get php SESSIONS to work with this socketed setup. I


already have sessions working for "normal" HTTP requests. You can pass
session IDs using cookies or with a POST/GET variable, as you know.


Now, I've set up two files, "tst1.php" and "tst2.php". TST1 sends TST2


some POST data, and attempts to relay the session id to maintain session
state:


#### tst1.php ####


---------------------------------------------------------------------------


-----------------------


include("HTTPClient.class");
session_save_path("mypathtosessions"); //No, this is not what I actually


have in my code, silly


session_start(); //Executes a new session.

//Create socket object
$HTTP = new Net_HTTP_Client("mydomain",80); //No, this is not what I


actually have in my code, silly


///////////////////////////////////////////////////////////////////////////


////////////////////////////


// (1) GET - This example attempts to send the session ID via the GET


method. If you execute the code below,


// it will "lock" up. However, if you change "PHPSESSID" to, say, "blah",


the code will not lock up.


// There's some problem, here!
$HTTP->Post("/~refcoord/tst2.php?PHPSESSID=".session_id(), // <--



array( "Bob" => "Jones",


"ID_we_need_to_pass_to_tst2" => session_id()


));


Sure it will lock up. tst1.php has the session file locked for itself,
and as you use the same session id, the same session file would be used
for tst2.php. You can use different session_save_paths for each file. Or
you can let tst2.php set its own session id and get the cookie.













--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to