stefangabos / Zebra_Session

A drop-in replacement for PHP's default session handler which stores session data in a MySQL database, providing better performance, better security and protection against session fixation and session hijacking
https://stefangabos.github.io/Zebra_Session/Zebra_Session/Zebra_Session.html
Other
172 stars 85 forks source link

_mysql_ping does not work when using MySQLi's mysqlnd backend #11

Closed soren121 closed 7 years ago

soren121 commented 8 years ago

Since PHP 5.4, mysqlnd has been the default backend driver for all MySQL extensions in PHP, including MySQLi.

However, mysqlnd does not support the mysqli::ping method, which Zebra_Session uses in its constructor. The PHP developers do not intend to fix this on their end, as automatic reconnection is considered dangerous.

We should replace the if(this->_mysql_ping()) check in the constructor with something that works with both libmysqlclient and mysqlnd. I chose to replace it with:

if($this->link instanceof MySQLi && $this->link->connect_error === null)

I can make a pull request with this change if you find it acceptable.