473,836 Members | 1,948 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Disconnecting client browser from php file

I'd like to initiate a php script using a standard httpd request, but
then allow the client browser to disconnect without terminating the
script. Freeing up the browser to access other functions on the site.

Whilst a combination of connection_time out() and ignore_user_abo rt()
can stop the script from terminating when the client calls
termination, i'd like to terminate the clients connection rather than
having to wait for the client to do it.

i.e.

<?
echo "Cleanup initiated";
return_control_ to_client_brows er_as_if_script _terminated();
run_verylong_du ll_cleanup_util ity_client_need _not_know_about ():
?>
Jul 17 '05 #1
18 2859

"chris" <ch***@remotego at.co.uk> wrote in message
news:10******** *************** ***@posting.goo gle.com...
I'd like to initiate a php script using a standard httpd request, but
then allow the client browser to disconnect without terminating the
script. Freeing up the browser to access other functions on the site.
I think that your understanding of how server-side scripting languages such
as PHP work is seriously flawed. When a PHP script generates a web page
(which is an HTML document) it immediately terminates, so by the time the
client browser receives the page and starts to render it the PHP script has
already died. If the user clicks on a hyperlink within the page then this is
transmitted as a brand new request, not as a continuation of the current
request. It may be to the same script as before, or it may be a different
script, but it is a new request.

There are no persistent connections between a web browser and a web server -
the HTTP protocol is totally stateless. I do not know what it is you are
trying to do, and your description leaves to to believe that you don't know
either.

--
Tony Marston
http://www.tonymarston.net

Whilst a combination of connection_time out() and ignore_user_abo rt()
can stop the script from terminating when the client calls
termination, i'd like to terminate the clients connection rather than
having to wait for the client to do it.

i.e.

<?
echo "Cleanup initiated";
return_control_ to_client_brows er_as_if_script _terminated();
run_verylong_du ll_cleanup_util ity_client_need _not_know_about ():
?>

Jul 17 '05 #2
On 7 May 2004 05:01:33 -0700, ch***@remotegoa t.co.uk (chris) wrote:
I'd like to initiate a php script using a standard httpd request, but
then allow the client browser to disconnect without terminating the
script. Freeing up the browser to access other functions on the site.
Browsers will often handle multiple http requests simultaneously; if
they're downloading a page with images, for example.
Whilst a combination of connection_time out() and ignore_user_abo rt()
can stop the script from terminating when the client calls
termination, i'd like to terminate the clients connection rather than
having to wait for the client to do it. <?
echo "Cleanup initiated";
return_control_ to_client_brows er_as_if_script _terminated();
run_verylong_du ll_cleanup_util ity_client_need _not_know_about ():
?>


You may be better off scheduling your cleanup utility with cron rather
than relying upon a client request to do it.

--
David ( @priz.co.uk )
Jul 17 '05 #3
I noticed that Message-ID: <c7************ *******@news.de mon.co.uk> from
Tony Marston contained the following:
I think that your understanding of how server-side scripting languages such
as PHP work is seriously flawed. When a PHP script generates a web page
(which is an HTML document) it immediately terminates, so by the time the
client browser receives the page and starts to render it the PHP script has
already died.

I used to think that but my experiences with odbc functions suggests
otherwise.

If I write

<?php
while($row = odbc_fetch_arra y($query)){

?>
<table>
<tr><td >Name:</td>
<td><?=$row['fullname']?> </td></tr>
....
</table>
and right at the end

}
odbc_free_resul t($query);
odbc_close($odb c);

The script can time out on slow connections. However:

<?php
$code="";
while($row = odbc_fetch_arra y($query)){

$code.= " <tr> ";
$code.= " <td>Name:</td>";
$code.= " <td>";
$code.= $row['fullname'];
//snip intermediate code
$code.= "</table>";
}
odbc_free_resul t($query);
odbc_close($odb c);
print $code;

Works just fine. Now I know you're a clever guy Tony, can you explain
this?
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #4

"Geoff Berrow" <bl******@ckdog .co.uk> wrote in message
news:ke******** *************** *********@4ax.c om...
I noticed that Message-ID: <c7************ *******@news.de mon.co.uk> from
Tony Marston contained the following:
I think that your understanding of how server-side scripting languages suchas PHP work is seriously flawed. When a PHP script generates a web page
(which is an HTML document) it immediately terminates, so by the time the
client browser receives the page and starts to render it the PHP script hasalready died.

I used to think that but my experiences with odbc functions suggests
otherwise.

If I write

<?php
while($row = odbc_fetch_arra y($query)){

?>
<table>
<tr><td >Name:</td>
<td><?=$row['fullname']?> </td></tr>
...
</table>
and right at the end

}
odbc_free_resul t($query);
odbc_close($odb c);

The script can time out on slow connections. However:

<?php
$code="";
while($row = odbc_fetch_arra y($query)){

$code.= " <tr> ";
$code.= " <td>Name:</td>";
$code.= " <td>";
$code.= $row['fullname'];
//snip intermediate code
$code.= "</table>";
}
odbc_free_resul t($query);
odbc_close($odb c);
print $code;

Works just fine. Now I know you're a clever guy Tony, can you explain
this?


I never use ODBC so I never have this problem.

--
Tony Marston

http://www.tonymarston.net

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/

Jul 17 '05 #5
I noticed that Message-ID: <c7************ *******@news.de mon.co.uk> from
Tony Marston contained the following:
Now I know you're a clever guy Tony, can you explain
this?


I never use ODBC so I never have this problem.


Pity, I was hoping for an insight.

Do you not agree that, on the face of it, it negates what you said?

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #6
Tony Marston <to**@nospam.de mon.co.uk> wrote:
I think that your understanding of how server-side scripting languages such
as PHP work is seriously flawed. When a PHP script generates a web page
(which is an HTML document) it immediately terminates, so by the time the
client browser receives the page and starts to render it the PHP script has
already died.


This is false. You might experience this kind of behavior when output
buffering is on (either in PHP or in the webserver itself).

BTW http/1.1 has a special feature to make "streaming" in http more
easy: chunked transfer encoding.

--

Daniel Tryba

Jul 17 '05 #7
chris wrote:
I'd like to initiate a php script using a standard httpd request, but
then allow the client browser to disconnect without terminating the
script. Freeing up the browser to access other functions on the site.


I don't know how to do exactly what you asked, but have you tried to

echo "\n</BODY>\n";

and then output nothing more from your script ? This will have the browser
render the page and then wait. This is what I did when I had to update site
statistics after each succesfull login of a memeber

--
Timothy Madden
Romania
-------------------------
And I don't wanna miss a thing
Jul 17 '05 #8
chris wrote:
I'd like to initiate a php script using a standard httpd request, but
then allow the client browser to disconnect without terminating the
script. Freeing up the browser to access other functions on the site.

I think what you're looking for is register_shutdo wn_function()
Searc at http://www.php.net/manual/en
--
Timothy Madden
Romania
-------------------------
And I don't wanna miss a thing
Jul 17 '05 #9

"Geoff Berrow" <bl******@ckdog .co.uk> wrote in message
news:lc******** *************** *********@4ax.c om...
I noticed that Message-ID: <c7************ *******@news.de mon.co.uk> from
Tony Marston contained the following:
Now I know you're a clever guy Tony, can you explain
this?
I never use ODBC so I never have this problem.


Pity, I was hoping for an insight.

Do you not agree that, on the face of it, it negates what you said?


No. The HTML output generated by your PHP script is not transmitted to the
client in bits and pieces as it is being generated, it is sent in one burst.

--
Tony Marston

http://www.tonymarston.net
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/

Jul 17 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4142
by: sc0ri0n | last post by:
Hi, I want to be able to tail -f log files on a different machine and display the results in a web page. Below code from the cgi works: $cmd = "rsh -l $acc $Host tail -f $LogFileName |"; $count=0; open LOG, $cmd or die "Could not open file: $!"; while (<LOG>){ $_ =~ s/\&/&amp;/g;
18
7391
by: cjl | last post by:
Hey all: I know that it is silly in the age of Google to 'lose' something on the internet, but I recently checked out a project that had implemented a database with a subset of SQL in pure client-side javascript. I forgot to bookmark it, and now I can't find it. Anyone?
5
3616
by: KathyB | last post by:
If someone could just explain this to me...I just don't get it! I have an aspx page where I retrieve several session variables and use xmlDocument to transform xml file with xsl file into an instruction document (not data based) - same as using an xml web control. The resulting html is on the client? but what about the server side of things? Trying to figure out how to change and save the xmlDocument. It I put a button OUTSIDE of the...
7
8202
by: Andreas Håkansson | last post by:
Hello, I'm building a small TCP based server which uses the Async commands. When a new connection is made to the server, I store the new socket in a hashtable, using the client IP as the key. Then I have a method in my server which is called Stop(). Now I would like for some advice on how to close down the server in a gracefull manner. I tried
7
7773
by: moondaddy | last post by:
I want to dynamically create a JavaScript file and cache it on the client for re-use. I know how to write javascript to a web page from the code behind, but I don't know how to actually create a file such as MyNewScript.js and then cache that on the client so all the pages of that session can use it. Can this be done? Thanks -- moondaddy@nospam.com
8
2708
by: DanB | last post by:
This is probably soooo simple but I can't seem to get it. I have a text file that I want users to download via a web page. I want the file to be saved to a default folder (or one that they choose) on the users / client file system. I have toyed with a Self-Extracting zip file but the contents of my zip file changes each time it is downloaded so that invalidates the exe file. Also the text file is so small it is a waste to zip it.
13
4343
by: Joner | last post by:
Hello, I'm having trouble with a little programme of mine where I connect to an access database. It seems to connect fine, and disconnect fine, but then after it won't reconnect, I get the error "operation is not allowed when object is open" so I take out the line of code: BookDetails.Connection1.Open and it comes up with the error "operation is not allowed when object
6
9540
by: dinoo | last post by:
Hi, I would appreciate if some one could help me out. I have to read a client side ini file in Aspx page and use that data in server side processing. Can any one help me out here? Please refer to a link if possible. Thanks, Dinoo
3
3241
by: =?Utf-8?B?UmludSBHb3BhbGFrcmlzaG5hIFBpbGxhaQ==?= | last post by:
Hi All, I have a ASP/C# application that connect to Oracle database . After issuing my SQL query if I close the browser or move into another page ( ie whle executing in the databse serevr) will the SQL execution in server continue or immediately stop.If it still continue how I can stop the execution (by disconnecting the present database connection ???). Please help.
0
10824
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10533
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10579
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9362
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7775
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6975
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5644
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
4003
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3103
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.