PHP has a very powerful session handling mechanism. By default it uses files, but you can use MemCache, MemCached or Redis, too and in some cases SQLite could be an option. These scenarios are provided with simple configuration settings. But if you have a Windows infrastructure then some of these "sounds-easy" scenarios do not really work. MemCache, MemChached are out-dated, Redis is not really available for Windows and the port from Microsoft is depricated. SQLite does not provide Row-Level-Locking mechanism that is required for a transaction intensive way of session handling.
So I thought it is clever to use an existing MS SQL Server that was already used for EA repositories.
You can find a lot of resources explaining how to write your own session handler, but none explaining the combination of SQL Server and what to configure without the need to adapt the code (meaning WebEA).
What is required:
MS SQL Server for PHP
installed as an extension please take care to use the fitting version to the PHP version
PHP.ini
This setting defines, that a user specific session handler should be used:
session.save_handler = user
This adds automatically the session handling to every php file interpreted:
auto_prepend_file = "[path]SSCESessionHandler.php"
SSCESessionHandler.php
Then you need a class that implements the SessionHandlerInterface:
class SparxCEFileSessionHandler implements SessionHandlerInterface
that means the following methods:
public function open($savePath, $sessionName)
--> here you open the connection to the database
public function close()
--> here you close the connection to the database
public function read($id)
--> here you read the session data
public function write($id, $data)
--> here you write the session data
public function destroy($id)
--> here you remove the entry of the session
public function gc($maxlifetime)
--> from time to time garbage collection takes place - a good place to remove out dated sessions
And at the bottom of this file - you should instanticate and start the Session Handler - because this will become the top most part of any php in the future of this installation
$handler = new SSCESessionHandler();
session_set_save_handler($handler, true);
session_start();