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

get_lock doesn't work #38

Closed thepurpleblob closed 4 months ago

thepurpleblob commented 3 years ago

This is probably a local issue but I'm stumped.

function read($session_id) (around line 500) fails with 'Zebra_Session: Could not obtain session lock'

If I dump the contents of result it shows that it contains no data - 0 rows. No error or warning is logged.

Any ideas?

stefangabos commented 3 years ago

you are probably using the same session in another tab and that is doing something that takes a long time and thus not releasing the lock. call session_write_close() before engaging in something that take a long time to process so you can continue to use the same session

thepurpleblob commented 3 years ago

I don't think so. The application doesn't run at all and it's just me on a test server. There's nothing else running. It's failing at (I presume) session_start.

It's coming back with this error instantly. It's not timing out. The timeout is the default 60 seconds. It's MySQL 8 if it makes any difference.

thepurpleblob commented 3 years ago

The problem is that rowCount() returns zero for the SELECT. I'm using Idiorm for database access and that is supplying the PDO object. I imagine it's changing some setting but I'm yet to spot what.

Some reading around casts doubt on the wisdom rowCount(). There seem to be a number of problems.

As far as I can tell your function query() for PDO only ever returns a single row of data, so the 'count' is really just a boolean anyway. Is there data or isn't there.

stefangabos commented 3 months ago

maybe the fix for #53 is related