Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy does sharing PHP sessions between concurrently open pages seem to work in FF, but not IE or Chrome?
    primarykey
    data
    text
    <p><strong>EDIT I just realized that I must have had a massive brain fart while writing the abbreviated code sample. See, I'm using smarty. Thus, I'm actually already using Kips's solution, because smarty displays after the session is saved</strong></p> <p>I've been working on implementing a resource manager (for condensing, compressing and minifying CSS &amp; JS) for a PHP site I'm working on and have run into an awfully strange problem. So when a user navigates to index.php, files are added to a resource manager object, which combines them into a single file and are included in the page via either <code>&lt;script src="resource.php?id=123&amp;ext=.js"&gt;</code> or <code>&lt;link href="resource.php?id=123&amp;ext=.css" /&gt;</code></p> <p>What it basically boils down to is that a file path is stored in a session on the accessed page and read from the session on the resource page. In FF, this works perfectly fine. In IE and Chrome, it does not.</p> <p>Here's a much-abbreviated code sample:</p> <p><strong>index.php</strong></p> <pre><code>&lt;?php session_start(); //Do a ton of stuff //Including adding several files to the resource object //Add the resource links to the head $smarty-&gt;append('headSection','&lt;link href="resource.php?id=&lt;?=$resourceID?&gt;&amp;type=.js" /&gt;'); &lt;/head&gt; //Save the resource file which: // - Outputs the file // - Saves a reference to it in session $_SESSION[$resourceID] = $file; //Let Smarty display $smarty-&gt;display($templateFile); ?&gt; </code></pre> <p><strong>resource.php</strong></p> <pre><code>&lt;?php readfile($_SESSION[$_GET['id']] . $_GET['type']); ?&gt; </code></pre> <p>What it seems like to me is that FF waits for an entire page response before making any new requests to the resources required by the page, while IE and Chrome function by starting a new request the second it is encountered. Due to this, this error basically boils down to a race condition.</p> <p>Can anyone confirm that this is indeed the way it works? And if so - how would I work around it?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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