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

前端 未结 12 2281
春和景丽
春和景丽 2021-02-14 02:03

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 w

相关标签:
12条回答
  • 2021-02-14 02:30

    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.
    0 讨论(0)
  • 2021-02-14 02:34

    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
    
    0 讨论(0)
  • 2021-02-14 02:35

    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

    0 讨论(0)
  • 2021-02-14 02:39

    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.

    0 讨论(0)
  • 2021-02-14 02:41

    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.

    0 讨论(0)
  • 2021-02-14 02:41

    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.

    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
    
    0 讨论(0)
提交回复
热议问题