Search code examples
mediawikiwiki

MediaWiki 1.22 - Session Storage


I am trying to use MySQL as session storage for MediaWiki.

I've added:

$wgSessionHandler = 'session_mysql';

to "LocalSettings.php", but I can't find any session table in associated MySQL DB.


Solution

  • If you set $wgSessionHandler = 'session_mysql';, you ask PHP to internally manage the sessions with a MySQL backend instead of the default file backend. In this case, you have to install and configure this MySQL backend yourself (by quickly searching I found https://github.com/repoforge/rpms/blob/master/specs/php-pecl-session_mysql/php-pecl-session_mysql.spec but this package seems quite old). In particular, you will have to choose the host, user, database and table to store your sessions.

    Instead, for your request, I suggest using the MediaWiki session cache manager with the MySQL backend. This will do the same thing as the previous solution, but this is properly integrated in MediaWiki. To achieve this behaviour, write in your LocalSettings.php:

    $wgSessionsInObjectCache = true; # MW internal session cache management
                                     # takes precedence over PHP management
    $wgSessionCacheType = CACHE_DB; # See documentation for other backends
    $wgObjectCacheSessionExpiry = 3600; # Default lifetime of the sessions
    

    It seems it doesn’t work with SQLite, but it works well with MySQL. In this cache, you can inspect the table objectcache where there are keys named wikiID:session:sessionsID among other possible cached objects.