11

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.

Community
  • 1
  • 1
JesseG17
  • 664
  • 1
  • 5
  • 17
  • Use [Fiddler](http://fiddler2.com/) and see if cookies are send from server to browser. If not - there is something wrong with your server. In either case update your question with findings. – Alexei Levenkov Apr 21 '13 at 04:13
  • How will I know that if that is happening? – JesseG17 Apr 21 '13 at 04:27
  • Look at response and see if cookies header is set. – Alexei Levenkov Apr 21 '13 at 04:38
  • What browser are you using? Have you tried a different browser? Are you running MW on the local machine or on a remote host? Is there anything between you and the web server that could be stripping cookies out? – halfer Apr 21 '13 at 10:02
  • 1
    As I said, I've used multiple browsers. I tried with Chrome, Safari, Firefox, and even Opera, and made sure that the cookies were enabled, but it still wasn't working. – JesseG17 Apr 21 '13 at 14:09
  • Oh, and I also tried IE. And it is run on a remote webserver @halfer. – JesseG17 Apr 21 '13 at 14:16
  • Righto, +1 to this. See @Alexei's point about checking cookies in headers (you can do this with the Web Developer toolbar in Firefox, and probably in many other ways too). – halfer Apr 21 '13 at 14:38
  • Thank you all very much for your help, I found a fix to it. I'm posting an answer here right now. – JesseG17 Apr 21 '13 at 16:14

12 Answers12

10

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.
the
  • 21,007
  • 11
  • 68
  • 101
JesseG17
  • 664
  • 1
  • 5
  • 17
  • 3
    Glad you fixed it. I'm not familiar with this software, but is the location where it is installed the web root for the site? If so, try accessing `http://yoursite/tmp` and `http://yoursite/tmp/` to ensure they are inaccessible. If you can see either through your browser - especially the first one, which might be a directory index! - then you have a security problem. – halfer Apr 21 '13 at 16:38
  • +1 for adding your own answer, that is encouraged here. Don't forget to tick it, to remote the question from 'unanswered' lists. – halfer Apr 21 '13 at 16:39
  • 2
    @halfer: I was just about to mention the same thing. (Ps. For MediaWiki, a more likely URL would be something like `http://yoursite/w/tmp/`.) – Ilmari Karonen Apr 21 '13 at 16:39
  • That makes sense @halfer, I'll make sure there's no security issues with the tmp directory. – JesseG17 Apr 22 '13 at 20:27
  • the issue is why i need session_save_path function, how do you find this method to solve this problem? – hugemeow Sep 14 '13 at 17:00
  • It is working for me by setting the directory outside of `public_html` (`session_save_path('../mediawiki-cookies-tmp');`) – Brett Zamir Dec 25 '15 at 19:52
5

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.

DevOops
  • 943
  • 2
  • 10
  • 21
3

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.

Nemo
  • 2,441
  • 2
  • 29
  • 63
  • 1
    After a complete day trying a lot of configurations finally Found your answer. The only that actually works. Fresh install of Wikimedia 1.3.0 + PHP-FPM 7.0 + Nginx 1.12. – Marcos Regis Jan 17 '18 at 23:46
2

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.

Steven
  • 21
  • 1
  • this is also the same root cause i had....i just had to delete the new [huge] file that i put on the server since the symptoms appeared – jbu Jul 16 '15 at 07:56
2

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

ilintar
  • 89
  • 1
1

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
Igor
  • 61
  • 5
0

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
OhBeWise
  • 5,350
  • 3
  • 32
  • 60
Metasharp
  • 9
  • 1
  • session.cookie_path is not pointing to a directory but handles the domain path see http://php.net/manual/en/function.session-set-cookie-params.php – Wolfgang Fahl Nov 16 '16 at 17:25
0

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.

OhBeWise
  • 5,350
  • 3
  • 32
  • 60
Teknow
  • 1
0

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
Community
  • 1
  • 1
Tony
  • 2,658
  • 2
  • 31
  • 46
0

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

John
  • 11
  • 1
0

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

Wolfgang Fahl
  • 15,016
  • 11
  • 93
  • 186
-1

Put

$wgDisableCookieCheck = true;

in your LocalSettings.php.

(source)

Geremia
  • 4,745
  • 37
  • 43