Tuesday, 03 December 2019 07:31

WebEA hosted in a loadbalanced scenario

Written by
Rate this item
(0 votes)

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


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"


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);



Read 2572 times Last modified on Wednesday, 04 December 2019 23:20
Peter Lieber

I am an extrovert promoter and results-oriented controller and director. It like creating new partnerships and relations. I like people that are talking with me and it is important for me to help and motivate others. I'm very self-motivated and I prefer doing thinks I really like. I need a lot of creative and open space. But I also need people doing the administrative tasks and people realizing the ideas.

My highest motivation is doing creative work with and around Enterprise Architect. (www.sparxsystems.de)

Login to post comments