|Classes of Francesco Danti||>||ATK4 Session||>||README.md||>||Download|
Session handler for atk4\data\Persistence (@see https://github.com/atk4/data)
initialize without atk4\ui
initialize with atk4\ui in App::init method
Create session table using atk4\schema
Create session table with SQL query
Constructor of SessionHandler
max session lifetime before eligible to gc, default value is set to 60 * 60 secods = 1 hour
percentage of probability of gc expired sessions, default is set to 1/1000 request. You have to consider few things for tweaking this value, because it must be sized to your project
if you use InnoDB deletes are slow and if set it low too many calls will have a little delay, if you set too high few calls will have a huge delay.
Considering disable it setting this value to false and use an alternative method like cronJob with frequency /2 * that calls code like example : demos/cronjob.php
Why i need to replace the default PHP Session Handler with this?
Because of file locking ( here a good article about the argument link)
Every call that use sessions read a file and set a lock on it until release or output, to prevent race conditions.
It's clearly a shame to have file locking on things that are usually static, like nowadays sessions.
Using an alternative you'll have for sure race conditions, BUT what race condition can be if you, usually, have only an ID in $_SESSION and that is nearly immutable from login to logout.
SessionHandler will substitute SessionHandler class in PHP and will store session data in database using atk4\data instead of using files.
In atk4\ui where async calls are massively used, this problem is much more evident.
You can add it without breaking your project, it already works, but is still in development and need a strong review for security issue.