|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38854 Can't access database in custom session handler with MySQLi
Submitted: 2006-09-16 16:43 UTC Modified: 2006-09-16 17:44 UTC
Avg. Score:4.4 ± 0.9
Reproduced:8 of 8 (100.0%)
Same Version:3 (37.5%)
Same OS:3 (37.5%)
From: thbley at gmail dot com Assigned:
Status: Wont fix Package: MySQLi related
PHP Version: 5.1.6 OS: Win32 / XP SP2
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2006-09-16 16:43 UTC] thbley at gmail dot com
MySQLi connection is broken when using a custom session handler. When using MySQL extension there is no problem.

Reproduce code:
$GLOBALS["DB"] = mysqli_connect("localhost","root","");


echo mysqli_query($GLOBALS["DB"],"show status")."OK\n";

function _login_session_none($param1="", $param2="") {
  return true;

function _login_session_write($id,$val) {
  echo mysqli_query($GLOBALS["DB"],"show status");

Expected result:
Object id #2OK
Object id #2O

Actual result:
Object id #2OK
Warning: mysqli_query() [function.mysqli-query]: Couldn't fetch mysqli in H:\sgs\src\test_mysqli.php on line 14


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-09-16 17:30 UTC]
Objects are destroyed before the session is written.
You may call session_write_close() prior shutdown.
 [2006-09-16 17:44 UTC] thbley at gmail dot com
No. Objects are not destroyed in MySQL, why should they in MySQLi ? session_set_save_handler() would be completely useless.
See the code examples of session_set_save_handler() at:

session_write_close() calls would need a huge change in the code. All kinds of die() or exit() would have to be extended with the close call.
Using oci8 and pgsql I also don't have the problem.

Please fix this.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Thu Mar 23 23:04:52 2023 UTC