Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Threading isn't available in stock PHP, but concurrent programming is possible by using HTTP requests as asynchronous calls.</p> <p>With the curl's timeout setting set to 1 and using the same session_id for the processes you want to be associated with each other, you can communicate with session variables as in my example below. With this method you can even close your browser and the concurrent process still exists on the server.</p> <p>Don't forget to verify the correct session ID like this:</p> <blockquote> <p><a href="http://localhost/test/verifysession.php?sessionid=[the" rel="noreferrer">http://localhost/test/verifysession.php?sessionid=[the</a> correct id]</p> </blockquote> <h3>startprocess.php</h3> <pre><code>$request = "http://localhost/test/process1.php?sessionid=".$_REQUEST["PHPSESSID"]; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $request); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 1); curl_exec($ch); curl_close($ch); echo $_REQUEST["PHPSESSID"]; </code></pre> <h3>process1.php</h3> <pre><code>set_time_limit(0); if ($_REQUEST["sessionid"]) session_id($_REQUEST["sessionid"]); function checkclose() { global $_SESSION; if ($_SESSION["closesession"]) { unset($_SESSION["closesession"]); die(); } } while(!$close) { session_start(); $_SESSION["test"] = rand(); checkclose(); session_write_close(); sleep(5); } </code></pre> <h3>verifysession.php</h3> <pre><code>if ($_REQUEST["sessionid"]) session_id($_REQUEST["sessionid"]); session_start(); var_dump($_SESSION); </code></pre> <h3>closeprocess.php</h3> <pre><code>if ($_REQUEST["sessionid"]) session_id($_REQUEST["sessionid"]); session_start(); $_SESSION["closesession"] = true; var_dump($_SESSION); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload