|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-08-26 23:21 UTC] mag at alcormizar dot com
Description:
------------
We have a web page that refresh 3 images every seconds, we use javascript + dhtml to accomplish this.
We use a timeout to call the UpdateImage function every second for each of the three images. Since there was a security risk in enabling sending cookies when changing the src attribute of an image, we need to send the Session ID as a GET request because we need our Session variables in test.php to select the right image to send back to the browser.
The calls to change the 3 images are made very close to one another, maybe even at the same time (but it sure is within a few milliseconds). Here's what happen :
1. Call to change the first image - Ok
2. Call to change the second image - Ok, but php change the Session ID after session_start() (why ???).
3. Call to change the third image - Fail, because the Session ID is not good anymore.
What happen is that the third call to the function is made <-before-> the Session ID is changed in the browser cookie, kind of a race condition.
Reproduce code:
---------------
function UpdateImage(IdImage)
{
var phpsessionid = GetSessionID(); //Get the PHPSESSID value from the cookie.
document.getElementById(IdImage).src = "http://example.com/test.php?PHPSESSID=" + phpsessionid + "xxxxxxxxx&idimage=id";
}
Expected result:
----------------
We would expect the Session ID not to change between those calls, unless someone can explain why it is changed like that.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 23 00:00:02 2025 UTC |
When submitting the function I forgot to remove the Xs, so the real function look like : function UpdateImage(IdImage) { var phpsessionid = GetSessionID(); //Get the PHPSESSID value from the cookie. document.getElementById(IdImage).src = "http://example.com/test.php?PHPSESSID=" + phpsessionid + "&idimage=id"; }