Here is the thing. My colleague is trying to overwrite the session processing of the structure we are using. This structure uses its own native PHP processing session by default, but now it is trying to implement a database layer between queries.
The problem is that the database object is not available because time sessions are more written, but it is available for other functions, for example, when data is read from sessions. This is wild behavior. Here's what we did:
register_shutdown_function('exithandler'); session_set_save_handler( 'sess_open', 'sess_close', 'sess_read', 'sess_write', 'sess_destroy', 'sess_gc' );
Each of these functions also writes one line to our log file, which we can track with the name of the function. This is done whenever a function is called. Now here are the two URLs that are being requested, the first is where the sessions are actually recorded (new data for the sessions), and the second where the session data has just been marked (and nothing is written). Here is the puzzle:
/login/ sess_open sess_read exithandler sess_write sess_close /account/ sess_open sess_read sess_write sess_close exithandler
Why is this behavior different? Why is the handler call called before the data is stored in the sessions and why is the same not true for a regular page, even if the same methods are actually called?
The problem is that none of our classes are already available after calling exithandler, I assume that the PHP garbage collector called __destruct () methods on all our classes, and they disappeared. This is just bad.
Does anyone know why PHP behaves this way?
kingmaple
source share