How to Fix a Cookie Error in WordPress

Cookies are one of the php functions used today in most content management systems and is extremely effective and effective, in this tutorial we will solve the cookie problem in WordPress.


What are a cookies

The cookie is responsible for storing sensitive information in the user’s browser so that each time a user visits a site, such as a user name and password, a text file is uploaded to the server by the browser, which will improve WordPress security and improve site loading speed. Was.

In some cases it may be difficult to use cookies and may bother the user. To fix the cookie issue, simply remove the ctrl + f5 buttons once the cookies and caches are removed or delete them through browser settings to resolve the issue. Be.

Cookies are blocked due to an unexpected output

Sometimes there is a cookie problem in WordPress from the site and the user is unable to fix it. In this case the site administrator has to check and fix the cookie issue. One of the common errors is “cookies are blocked due to unexpected output” This requires full access to the site.

How to solve a cookie problem in WordPress

First of all, check that the cookie is enabled on your browser and that the cookie has not been disabled due to the add-ons installed, then erase all your cookie information and browser cache once, and make sure it is not up to you.

If the cookie issue still persists, you should first check the WordPress plugins to prevent this from happening.

Disable plugins

To do this, log in to your wp-content directory from your host then rename the plugins directory to another name to disable all plugins, then double-check your site if the problem was resolved. And to fix it you need to enable individual plugins and check the site again.

Immediately after the problem resumes, you should remove the cause plugin to fix your site and fix the cookie problem in WordPress permanently.

WordPress Theme Checker

If you were still having trouble disabling your plugins, you should go to your site template

and disable it this time. If the problem is fixed, you should think about your site template.

This may be due to changes to your site’s functions.php file,

so you should carefully examine the codes as this is site wide and affects all pages of the site. Even a single space can cause Cookie problem in WordPress.

If there is a problem with your code, add the following code snippet into your template’s functions.php file to fix the cookie problem in WordPress.

  // fix for cookie error while login.
 function set_wp_test_cookie () {
 setcookie (TEST_COOKIE, '
 Cookie check ', 0, COOKIEPATH, COOKIE_DOMAIN);
   setcookie (TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN);
 add_action ('after_setup_theme', 'set_wp_test_cookie', 101);

If the problem still persists, another way to fix the cookie problem

in WordPress is to open the wp-login.php file in WordPress and look for the following code inside it. This may be due to a change in the following code Correct it if it occurs.

  // if (isset ($ _ POST ['testcookie']) && empty ($ _ COOKIE [TEST_COOKIE]))
 // $ user = new WP_Error ('test_cookie', __ ("<strong> ERROR </strong>": Cookies are blocked or not supported by your browser. You must <a href = 'http: // /cookies.html'> enable cookies </a> to use WordPress. ”));
 $ user = wp_signon (”, $ secure_cookie);

In general, keep in mind that before making any changes to any file on your website,

make a backup to recover it if the problem arises.

How helpful was the training for you?

Leave a Reply

Your email address will not be published. Required fields are marked *