php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55151 Unable to open sessions while MySQL DB connection is open
Submitted: 2011-07-06 14:34 UTC Modified: 2011-07-07 05:28 UTC
From: dkettmann at kmcis dot com Assigned:
Status: Not a bug Package: Session related
PHP Version: 5.3.6 OS: RHEL/CentOS
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: dkettmann at kmcis dot com
New email:
PHP Version: OS:

 

 [2011-07-06 14:34 UTC] dkettmann at kmcis dot com
Description:
------------
On RHEL(or Centos) 5.6 running any available PHP package thru RedHat and the latest version of PHP (5.3.6).

Run first script provided in a browser, then while that is running, fire up the second script. The second script will not finish until the first one calls the session_write_close() function.

Test script:
---------------
=== 1.php ===
<?php
$counter=1;
$DB= mysql_connect(localhost,$user,$pass,true);
mysql_select_db("database");

session_start();
echo "Starting...\n";
while ( $counter <= 5 ) 
{
	echo "$counter ... \n";
	sleep(2);
	$counter++;
}
echo "Done!... \n";
session_write_close();
?>

=== 2.php ===
<?php
session_start();
echo "TESTING!\n";
session_write_close();
?>

Expected result:
----------------
When both scripts are run at the same time, the second script should exit (nearly) immediately after opening a session, echoing the TESTING line, then closing the session. After the while loop is done in the first script, it should exit as expected. 

Actual result:
--------------
When the both scripts are executed at the same time (or one right after the other), the second script hangs at the 'session_start()' line until the first script is done.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-07-07 05:28 UTC] johannes@php.net
-Status: Open +Status: Bogus
 [2011-07-07 05:28 UTC] johannes@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

If you do a session_start() the session file is locked till the session is closed again. This is needed to avoid loosing data from concurrent requests. In your example: If 2.php would change the session data this would be overwritten by the old state in 1.php.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 16 21:01:33 2025 UTC