Extension:Auth viaMySQL

What can this extension do?
This extension will automatically Authenticate (Login) a user with data provided from an existing MySQL database. Another web page or program can be used to login an existing user from that web page or program upon entry to the MediaWiki associated with that web page or program. Logout is accomplished by clearing the database global variable and associated cookie.

The Login and Create Account and the Logout url's in the Personal Tools tool box will not be shown using Auth_viaMySQL extension.

Usage
To Use this extension you need to adjust your LocalSettings.php as shown below, and create Three separate PHP files included in the code listed below in the code section of this page.

Create PHP file: MySQLActiveUser.php        save to your web page directory Create PHP file: Auth_viaMySQL.php          save to the MediaWiki/extension/Auth_viaMySQL directory Create PHP file: CacheTimer_viaMySQL.php    save to the MediaWiki/extension/Auth_viaMySQL directory

Installation
To install this extension, add the following to LocalSettings.php:

Configuration parameters
Page caching must be turned off or else MediaWiki will cache and save the database username and the user will appear to always be logged in even if the user has logged out.

Setting wgCacheEpoch the way I have shown above will cause MediaWiki to expire the cache epoch at user log in. This way all pages get rebuilt for the new user.

Setting wgCachePages to false will cause MediaWiki to NOT cache all client side pages.

I found the settings set in this manner was the only way Auth_viaMySQL would work properly.

Code
Copy this first section of code to a file called MediaWiki/extensions/Auth_viaMySQL/Auth_viaMySQL.php

Save this next piece of code to a file called MediaWiki/extensions/Auth_viaMySQL/CacheTimer_viaMySQL.php

Save this next piece of code to a file called ../MediaWiki/MySQLActiveUser.php

Note: This file is to be stored in the directory just BEFORE the MediaWiki installation directory!

In your login scripts for your web page add something like:

The next step is very important if you also require LOGOUT!

In your logout scripts for your web page add something exactly like:

Note: When I refer to MediaWiki as a directory I mean the default directory you have installed MediaWiki to.