A partial archive of https://discourse-mediawiki.wmflabs.org as of Saturday May 21, 2022.

How to share session with Wiki

renwang101

Our website already has its session created and we are planning to install Wiki in the same web server and share the same session after user login. I found Wiki cleans up all the $_SESSION data after loading a wiki page. I wonder how to access wiki session information via PHP code?
I did tried to use the Wiki global $wgRequest to getSession in my PHP code, but $wgRequest is NULL, where is it created and when?

Tgr

In general we don’t support that. Sessions are internal state of an application and trying to share it between different applications rarely ends well. MediaWiki doesn’t store its sessions in a way that’s accessible to other applications, anyway. What is it you are trying to achieve? Some kind of shared authentication? You can write a custom authentication provider or session provider.

$wgRequest is initialized in inlcudes/Setup.php (most things are). MediaWiki globals are not going to exist in your application, global variables are internal to a single request.

renwang101

Thanks again for your response. I will dig into session provider implementation.

I can understand MediaWiki doesn’t want to share its sessions, but it should not kill other apps sessions as well. Based on my testing, looks like it triggers a kind of “session destroy” whenever a request sending to a Wiki URL.

Tgr

MediaWiki sets a custom session name so unless you configured one or both applications in strange ways there should be no conflict.