Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6720669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:14:22+00:00 2026-05-26T09:14:22+00:00

I have the following problem: A PHP Script is called via Ajax. The script

  • 0

I have the following problem:

A PHP Script is called via Ajax. The script itself closes the connection using the following lines

ignore_user_abort(true);
header("Content-Length: 0");
header("Connection: close");
flush();

and then starts sending out a bunch of mails in the background using phpMailer (in a loop and using sleep(1) after each mail – in the future I want this to be a random amount of seconds after 5 sent mails). Using FireBug, I can see that the connection to the script is directly terminated. The mails are being sent as well.

However, I cannot open any pages while the script is running in the background – they keep loading until the background script obviously has finished. The strange thing: The script doesn’t seem to block the whole server, as the connection restriction only applies to the browser that initiated the background script. So after I start the script in – let’s say – FireFox, I can still access the pages on the server in Chrome.

What could be the cause? Is there a limit of open MYSQLi-connections per browser (per session, that is…) – I couldn’t find anything on this… Or is the browser (although FireBug says that the connection has been terminated) nevertheless waiting for a response of the script?

How could I solve this?
Thanks in advance for any help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T09:14:23+00:00Added an answer on May 26, 2026 at 9:14 am

    A PHP script cannot close the client<->server connection except by exiting. doing a Connection: close header doesn’t do anything either, as that’s for client->server requests, and is the default action anyways, unless the client specifically requests Connection: keep-alive.

    The “works in other browsers” behavior you’re seeing is generally due to PHP locking the session file while a request is active. The different browsers won’t share cookies, so each browser has its OWN separate session. So while Firefox is tied up with this background request, the session that Chrome is using is completely unaffected.

    If you want to continue being able to use FF while it’s waiting for this mail script to process, then issue a session_write_close() before you enter the mailer loop. That will close and unlock the session file, and let you continue using the site in another tab of FF.

    If you want this script to be truly independent of the browser, then it’ll have to pcntl_fork itself into the background. This forked child can handle the processing, completely unattached to a browser, and the original script can exit, allowing the connection to close.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem with the following piece of PHP script: <?php abstract class
i have following lines included at the bottom of my index.php: <script type=text/javascript language=javascript
I have the following problem using subversion: I'm currently working on the trunk of
I have the following problem using template instantiation [*]. file foo.h class Foo {
I have the following problem in my Data Structures and Problem Solving using Java
My jQuery code (using ajax) request's data from a local php script (pgiproxy.php). This
I have the following problem: I use a script that saves the referer URL.
I have a file called: file.php contained in this file is the following code:
I have a PHP Script with the following code: $sql = UPDATE tbl_p2e_place SET
I have a script called 'sess-start.php' which lies in an /include directory within my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.