After installing a MediaWiki, I tried it out. User registration worked fine, but when I tried logging in, I got the following error:

"Wiki uses cookies to log in users. You have cookies disabled. Please enable them and try again."

This error seems to say that the local cookie wasn’t set, but come on—why would logging in need a wiki? Isn’t storing the session enough?

I googled it and found what seemed to be useful info:

1. Open to LocalSettings.php 2. Go to the bottom of the page, and enter in the following code: session_save_path("tmp"); 3. Next create a directory called tmp in the folder where you have MediaWiki installed. 4. Done!

I tried it, and surprisingly it stopped throwing the error. So this seemed to be the cause: there was a problem with the PHP session storage location. But this fix looks super unreliable—storing sessions in the current directory is just asking for trouble. At least it pointed me in the right direction; probably something was wrong with session storage.

Since it was an httpd web server, I checked the error log directly (only thought of checking the http log at this point—pretty lame), and found that every time I logged in it reported something like:

.... PHP Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/var/lib/php/session) in Unknown on line 0, referer: ...

Obviously, this was the cause. As I had guessed, the default session storage path (/var/lib/php/session) had permission issues.

Bash
$ ls -al /var/lib/php
total 12
drwxr-xr-x  3 root root   4096 Sep 30 05:47 .
drwxr-xr-x 27 root root   4096 Oct 26 04:02 ..
drwxrwx---  2 root apache 4096 Sep 30 05:47 session

I found the session directory belonged to the apache user, while in the httpd server config I was using a different user.

Bash
# chown -R my_usr:my_usr /var/lib/php/session
After that, the error message no longer appeared. Done and dusted.