EDIT I ββjust realized that I must have had a massive brain fart when writing a shortened code sample. You see, I use smarty. So I actually already use the Kips solution, because smarty is displayed after saving the session
I am working on a resource manager implementation (for compacting, compressing and minimizing CSS and JS) for the PHP site I'm working on, and ran into a terribly strange problem. Therefore, when the user navigates to index.php, the files are added to the resource manager object, which combines them into one file and is included in the page through <script src="resource.php?id=123&ext=.js">or<link href="resource.php?id=123&ext=.css" />
Basically, it boils down to the fact that the file path is stored in the session on an accessible page and is read from the session on the resource page. In FF, this works fine. In IE and Chrome, this is not the case.
Here is an example with abbreviated code:
index.php
<?php
session_start();
$smarty->append('headSection','<link href="resource.php?id=<?=$resourceID?>&type=.js" />');
</head>
$_SESSION[$resourceID] = $file;
$smarty->display($templateFile);
?>
resource.php
<?php
readfile($_SESSION[$_GET['id']] . $_GET['type']);
?>
It seems to me that FF is waiting for a full response to the page before making any new requests to the resources required by this page, while IE and Chrome work by launching a new request, the second of which occurs. In this regard, this error mainly comes down to the condition of the race.
Can anyone confirm that this is really the way it works? And if so, how would I get around him?
source
share