Fixing issue of “Blocked or unwanted cookies”

Cookie bị từ chối

Errors related to cookies being blocked or not supported can often occur when trying to log in to a WordPress site. This article offers solutions to fix such errors, especially when caused by security plugins, caching plugins, or changes in server or hosting services. One solution involves temporarily deactivating security and caching plugins, while another entails editing the wp-config.php file. If these solutions do not work, editing the functions.php file may resolve the issue. By following these steps, users can address the “Cookies were blocked or unexpectedly exported. You must enable cookies to use WordPress” error and continue using their WordPress site seamlessly.

Errors during the development process can be frustrating, especially when you encounter the message, "Cookies were blocked or unexpectedly exported. You must enable cookies to use WordPress." This particular error typically shows up when attempting to log in to your WordPress site. The good news is there are ways to address and fix this issue.

Contrary to what the error message implies, the problem may not be solely related to blocked cookies. In many cases, this error is triggered by factors such as security plugins, caching mechanisms on your website, or changes in server/IP addresses post website migration to a new host. Sometimes, a simple browser refresh can resolve the error, but if that doesn’t work, you may need to explore other solutions.

Reasons for the Error: Cookie blocked or unexpectedly output

When encountering a cookie error on your WordPress site, it could stem from a few main reasons. The two most common causes are related to security plugins impacting cookie handling and login processes or conflicts arising from server changes. Fortunately, these issues can be addressed with relative ease.

See also  Interest Rate Calculator Plugin for WordPress

Security Plugin or Memory Interference

Security and caching plugins play a vital role in your site’s functionality but can sometimes disrupt cookie creation and login processes. This disruption may lead to the error message "Unexpected cookie blocked or output. You must enable cookies to use WordPress." To troubleshoot, temporarily disable these plugins by renaming the plugin’s folder.

To do this, access your site via FTP or a file manager plugin and rename the plugin’s folder (usually located at /wp-content/plugins/plugin-name). After this step, attempt to log back into your WordPress dashboard. If the issue is resolved, consider reactivating your security and caching plugins while notifying their developers about the cookie-related problem.

"WordPress Unsupported Cookie Error" After Server Changes

If you’ve recently transferred your WordPress site to a new host while maintaining the same domain, conflicts between existing browser cookies and the new host may arise. In such cases, clearing your browser’s cookies and attempting to log in again could resolve the error.

Resolving the "WordPress Cookie Enable Error" via wp-config.php File

To rectify the cookie-related error, you can access the wp-config.php file in your website’s root directory. Add the following code snippet at the end before the comment “/ That’s all, stop editing!…/.”:

define('COOKIE_DOMAIN', $_SERVER['HTTP_HOST'] );

Refresh your browser and attempt to log back into your website to see if the issue persists.

Fixing the "Cookies are blocked or not supported" Error through Editing functions.php File

If the previous solution doesn’t resolve the issue, consider following these three steps outlined below:

Step 1: Access and Edit functions.php File

Locate and open the functions.php file in your site’s theme folder (usually at wp-content/themes/theme-name/functions.php) through cPanel file manager or FTP.

See also  Guide to custom term field in Wordpress

Step 2: Insert Code into functions.php File

Copy the provided code snippet and paste it at the end of the functions.php file.

if ( SITECOOKIEPATH != COOKIEPATH ) {
    setcookie(TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN);
}

Step 3: Save the File

After adding and saving the modifications to the functions.php file, re-upload it to your site. This action should help eliminate the error message.

By following these instructions, you should be able to address and resolve the "Cookies were blocked or unexpectedly exported" error efficiently. If you found this guide helpful, consider exploring more topics in the WordPress section for additional insights. Stay updated with the latest articles by following the Hocwordpress Group fan page.

Rate this post

Related posts