php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #11560 to many sessions are generated when using set_session_save_handler with mysql
Submitted: 2001-06-19 11:01 UTC Modified: 2001-06-26 07:26 UTC
From: martin at gamingeye dot com Assigned:
Status: Closed Package: Session related
PHP Version: 4.0.5 OS: Red Hat 7.0
Private report: No CVE-ID: None
 [2001-06-19 11:01 UTC] martin at gamingeye dot com
Using a session_handler like this one: http://gateway.digitaria.com/~chris/php/mysql_session_handler/mysql_session_handler.phps

Using a mySQL-database.

Have the following configure './configure' '--with-mysql' '--with-apache=../apache_1.3.20' '--enable-track-vars' '--enable-trans-sid' '--enable-ftp' '-disable-debug'

The problem: I have noticed that if you use set_session_save_handler with mysql and you don?t accept cookies and there is a broken image on the page, PHP generates to many sessions:
This is an example code that generates this error (named test.php3):

<?php
 mysql_connect ("localhost", "user", "pass");
  include("the session file like the one linked above");
  session_start();
?>
  <img src="fdsafdsaf.jpg">
<?php
   // count the number of sessions stored in the database
    $numsessions = mysql_num_rows(mysql_query("select * from sessions"));
    echo $ numsessions;
?>
<br>
<a href="test.php3">test</a>


Notice how the number of sessions are added, but you still have your same session id. What happens is that PHP generates a number of session ids, that are never used. This problem doesn?t occur if you have cookies enabled, or don?t uses set_session_save_handler.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-06-20 10:00 UTC] martin at gamingeye dot com
Using a session_handler like this one:
http://gateway.digitaria.com/~chris/php/mysql_session_handler/mysql_session_handler.phps

Using a mySQL-database.

Have the following configure './configure' '--with-mysql' '--with-apache=../apache_1.3.20'
'--enable-track-vars' '--enable-trans-sid' '--enable-ftp' '-disable-debug'

The problem: I have noticed that if you use set_session_save_handler with mysql and you
don?t accept cookies and there is a broken image on the page, PHP generates to many sessions:
This is an example code that generates this error (named test.php3):

<?php
 mysql_connect ("localhost", "user", "pass");
  include("the session file like the one linked above");
  session_start();
?>
  <img src="fdsafdsaf.jpg">
<?php
   // count the number of sessions stored in the database
    $numsessions = mysql_num_rows(mysql_query("select * from sessions"));
    echo $ numsessions;
?>
<br>
<a href="test.php3">test</a>


Notice how the number of sessions are added, but you still have your same session id. What
happens is that PHP generates a number of session ids, that are never used. This problem
doesn?t occur if you have cookies enabled, or don?t uses set_session_save_handler.

I have also noticed that the image doesn't need to be broken, It can also be a gif and only contain a transparent colour. This generates the same error.
 [2001-06-26 07:26 UTC] martin at gamingeye dot com
I found what the problem was. When there is a broken image on the page, the 404-page was loaded. On that page sessions were loaded again, causing the error.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 20:01:31 2024 UTC