Lifetime of Filehandler within Session
| From: | Dirk dot Dinger at dignos dot com | Date: | Thu, 18 Jan 2001 16:39:48 +0000 |
| Subject: | Lifetime of Filehandler within Session | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-5103@lists.php.net to get a copy of this message | ||
Hi PHP cracks,
I need your help with my litte problem here:
I need to setup and maintain a tcp-socket connection within a PHP session,
because the service on the other side
keeps track of the client's state and decides at runtine which html-page is
to be displayed as a result of the
users form-entries and also manages the database-IO.
given the code snippet below, I discovered that variable $dynamx_result is
set correcty when page2.php is reached
while $jds_connection is 0 (in scope of page1.php it is something like
resource#1) !
Is there something special when filehandles are registed within sessions ?
Where is the difference ?
Any help would be great.
Dirk
----------------------------------------------------------------------------
-------------------------------------------------------------------------
page1.php:
========
require("lib.php");
$jds_connection = -1;
$dynamx_result = "@<CMD> <session> <URL>";
$status = dynamx_LogIn($username, $password);
// Login ok ?
// start new session, register vars and redirect to page given by
$dynamx_result
if ($status==1) {
session_start();
session_register("jds_connection");
session_register("dynamx_result");
// redirect to page2.php
header("Location:
$dynamx_redirect?".session_name()."=".session_id());
exit;
}
...
page2.php:
========
<?php
session_register("jds_connection");
session_register("dynamx_result");
?>
<title>Beispielformular - <?php echo $jds_connection?> - <?php echo
$dynamx_result?></title>
lib.php
=======
function LogIn( $a_username, $a_password) {
global $jds_connection;
global $dynamx_result;
$jds_connection = fsockopen(JDS_SERVER_HOST,JDS_SERVER_PORT);
...
// do some communication here and set $dynamx_result accordingly
}