Extension:VarsInSession

The VarsInSession extension allows the creation/usage of persistent variables in the Session object through three parser functions. These variables persist across multiple HTTP requests until the session cookie is removed or expires from the browser. By default this is when the user closes their browser.

Usage
The #svarset and #svar-set parser functions are synonyms, and set a variable to the given value. The parameter is required. The is optional, and will be the null value if not provided.

The #svarget and #svar-get parser functions are synonyms, and get the value of a variable. The parameter is required. The is optional, and is the returned value if does not exist.

The #svar-isset parser function returns "true" if the variable has been previously set, or returns the empty string if the variable has not previously been set.

NOTE: Some versions of Mediawiki do not create a $_SESSION global object variable for users that are not logged in, or it is created very late in the startup sequence. If you find you are having trouble with variables you set with this extension not persisting, it may be due to the lack of $_SESSION. In order to ensure this object exists prior to use, add this code to your LocalSettings.php: global $wgSessionStarted; if (! $wgSessionStarted) { wfSetupSession; }

Code

 * VarsInSession.php