How can I fix the MediaWiki error "Wiki uses cookies to log in users. You have cookies disabled. Please enable them and try again."?

StackOverflow https://stackoverflow.com/questions/16127882

  •  11-04-2022
  •  | 
  •  

Question

The problem I am having is that I can not log on to my newly created wiki that I made using MediaWiki. I have searched the web for an answer, and the ones I found did not help with this specific issue (like this one: problem with mediawiki cookies) I have tried with multiple browsers and changed the setting to make sure that cookies are enabled, but I keep getting the same error:

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

I'm not sure whether this is a problem with my current version of PHP, which is currently 5.3, or a setting in my wiki.

Was it helpful?

Solution

I found a fix, I'll put it in steps:

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

OTHER TIPS

If you are using NGINX + PHP-FPM the previous answers will likely not solve your problem.

From my experience, this issue is caused when php-fpm doesn't have write access to the cookie_path. You can find this path by running:

php-fpm -i|grep --color cookie_path

See what your cookie_path is, then stat the folder and ensure your php-fpm user has write access to it.

To resolve this issue using Nginx and Php-Fpm, I had to change my cookie_path from it's default of / (seriously, why would this be a default?) to /tmp.

After restarting nginx and php-fpm, it works perfectly.

The easiest solution, also recommended by Aaron Schulz, is generally to set

$wgSessionsInObjectCache = true;
$wgMainCacheType = CACHE_ANYTHING;

in your LocalSettings.php. In recent PHP you'll have OPcache enabled by default; if no accelerator is available, at worst this configuration will use the database.

See also cache documentation.

I also had this issue ...

All my browsers were complaining about cookies being turned off....

I thouhgt a group policy had been implemented to disable cookies. After conferring with my server support team that nothing as such had been implemented I decided to remote to the server.

The server was complaining about low disk space. I cleaned up the disk by deleting some old unrelated files.

Tried to logon again from my browser and all was Ok.

One answer which hasn't been mentioned here - make sure your file system isn't out of space.

same thing may happen when memcached is used to store session files. in this case wiki will be unable to write cookies neither in / neither in /tmp. if you see in error.log something like "file not found (11211:9001/qweqweqweqweqe)" this will mean, that you have memchached installed and configured and you need to append the following lines in LocalSettings.php:

$wgMainCacheType = CACHE_MEMCACHED; 
$wgParserCacheType = CACHE_MEMCACHED; # optional 
$wgMessageCacheType = CACHE_MEMCACHED; # optional 
$wgMemCachedServers = array( "127.0.0.1:11211" );
$wgSessionsInMemcached = true; # optional

Just ran into this issue on a Win2008 R2 server running IIS, when creating a user gave this (red) msg:

Account creation error The user account was not created, as we could not confirm its source. Ensure you have cookies enabled, reload this page and try again.

Also if a user tried to log into the Wiki, they would get this (red) msg:

Login error (WikiName) uses cookies to log in users. You have cookies disabled. Please enable them and try again.

Failed attempts:

  • I tried JesseG17's solution, but could not save changes to the localsettings.php file (despite stopping the server).
  • I checked permissions on the temp location, but that didn't help.
  • I changed tried changing the temp location via IIS's PHP manager, but that didn't change anything.

What finally did work was to use IIS's PHP manager to change the MediaWiki's PHP settings; session.use_cookies from 0 to 1

This solved the problem without any reboot.

Be root:

su -

Then edit the php.ini file:

nano /etc/php5/apache2/php.ini

And set those variables to /tmp:

session.save_path = "/tmp"   
session.cookie_path = "/tmp"

You can also correct the permissions just in case:

chmod -R 1777 /tmp

I'm adding a new answer because my setup was slightly different, and the steps I took were similar but not identical to everyone else's.

I installed MediaWiki on CentOS with NGINX. After running it successfully for a few months, I started to get the same cookie error out of nowhere.

enter image description here

The issue I had was that the php-fpm user lacked access to the session.save_path folder. I don't know why it happened, but here's now I fixed it.

I ran a variation of SprintCycle's command to identify where the sessions were stored:

php-fpm -i|grep --color save_path

In my case, it was /var/lib/php/session.

Then I changed directories and set permissions:

cd /var/lib/php
chmod -R 1777 session

I restarted the services, and everything worked again.

service nginx restart
service php-fpm restart

Another thing to check is if your session tmp directory is full. Symptoms are "write failed" messages in your http server error log. Duh!

I had to uncomment the wgCookieSecure setting in LocalSettings.php:

#$wgCookieSecure=true;

only found this after having checked that another wiki on the same computer ran just fine with similar settings. So to debug you might want to install a fresh mediawiki in a neighbour directory and check whether that gives you any trouble. Then you can go thru all the suggestions here as well as the one at https://www.mediawiki.org/wiki/Topic:Rg3w5u0e70fs8l4e

Put

$wgDisableCookieCheck = true;

in your LocalSettings.php.

(source)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top