views:

88

answers:

2

Hello guys.

I have page main.html which is a client application for a specific server. The main.php is an window with three frames.

main.html

<frameset frameborder=no border=0>
 <frame name='top1' src='top1.php' frameborder=no scrolling=no>
        <frame name='top2' src='top2.php' frameborder=no scrolling=no>
 <frame name='firstpage' src='firstpage.php' frameborder=no scrolling=auto>
</frameset>

firstpage.php

<?php 
....
....
require_once("connection.php");
// connection.php is a class which opens a socket and establishes with another server.
set_time_limit(0);
ignore_user_abort();

function parse($line) {
//parses $line returns $a which contains some data etc
....
return $a;
}

$connect= new Connection();
.....
$line=$connect->socket_read(1028);
.....
while ($i<200) {
$GLOBALS[userdata][$i]=parse($line);
.......
}
?>

firstpage.php is a large script and i have trimmed majority of firstpage.php for reasons of legibility. connect.php and firstpage.php are working exactly the way i desire.

I need to have the $GLOBALS[userdata] available in top1.php and top2 for further processing. Is there anyway i can access the $GLOBALS[userdata] WITHOUT instantiating connect.php again? (The data processing that i wish to do in top1.php and top2.php CANNOT be done in firstpage.php for reasons i cannot discuss here.) I cannot reinstantiate connect.php as the data from the server already to firstpage.php will not be resent by my server.

I have realized that since firstpage.php runs infintely $GLOBALS is not getting written. Tried session_write_close immediately after $GLOBALS[userdata][$i]=parse($line); in the while loop. But that didnot help.

I have also found that the SESSIONID in top1.php, top2.php and firstpage.php is the same.

Can anyone point me in the right direction?

Thanks!!

+5  A: 

The pages are handled as completely separate requests, so you can't share data between them in a traditional sense.

Theoretically could use the session to do it since all the pages would be loaded as part of the same session. However, the order in which they are loaded isn't exactly predictable, so you couldn't be sure that one page had finished when the other was being loaded. So in practice that probably wouldn't work either.

Yet another reason why frames cause problems..

Eric Petroelje
+1 Don't use frames to implement a design. Use it if you really want to show two different web sites in one browser window. (Although IFRAME is prolly better for that..)
0scar
A: 

I think frames is not the issue. I have a script which runs infintely.

Since i have instantiated a class and the script is still running i presume that the properties / data members of the class must be available somewhere. Is there any way to access those i.e. data members / properties of an already instantiated class?