php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34275 Session ID change when multiple javascript call occurs simultaneously
Submitted: 2005-08-26 23:21 UTC Modified: 2005-08-28 01:13 UTC
From: mag at alcormizar dot com Assigned:
Status: Not a bug Package: Session related
PHP Version: 5.0.4 OS: windows xp - 2000
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mag at alcormizar dot com
New email:
PHP Version: OS:

 

 [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.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-08-27 05:39 UTC] mag at alcormizar dot com
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";
}
 [2005-08-28 01:13 UTC] sniper@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 31 23:01:28 2024 UTC