Design/build: WordPress themes

from design prototype to theme : how to get started

cookie error fix

There is one seemingly common issue you might get while working on your sites: an odd error stating the lack of cookie support (despite correct details given and cookies enabled).

“ERROR: Cookies are blocked or not supported by your browser. You must enable cookies to use WordPress.”

Usually, once you’re set up and switching themes, installing/removing plugins etc ~ all will hold up fine. You can log in and out as you need. Some plugins are fairly light-weight and won’t touch any major settings. Others however will go deeper ~ cache and security plugins will edit files to perform their functions.

This cookie error is usually caused by these edits or when you change your server. In short, settings for the cookie domain itself are wrong with your WP install, rather than this being an issue with cookie support in your browser.

NOTE: this is one of the reasons why I advised you not to use any performance enhancing or security plugins during the early stages of your theme build. These are great plugins and will serve their purpose in the end ~ so you should consider them and set up your selected ones just before launch. Prior that point though it will be better not to risk any of the caching or security plugin interfering with your work :)

Troubleshooting login error

The WP crowd primarily offers up two solutions to this problem: to edit the wp-config.php file or to add to the functions.php file. Both will resolve this error by redefining the cookie domain.


While you should not touch any of the core WP files, ie the files inside the main directory of the WP site, – this is the one exception, the only file to use for edits to configuration details. You might have used this file already during a manual setup, for example.

1. open the wp-config.php file and find this comment

(This file is in the main WordPress directory.)

/* That's all, stop editing! Happy publishing. */
2. paste the following line just before this comment and save the file

This will define the cookie domain — next up, clear your cache etc… and try logging in again. This should have solved the problem.

If this does not work, comment out or remove the line and try the next option.


The function file can perform the same function by setting the cookie path. Again, we’ll add to an existing file, in this case, the file is part of our theme.

1. open the functions.php file

(This file is in your theme directory.)

CAUTION: the functions file is quite special and very powerful ~ well worth exploring and experimenting with! Know that errors here can throw up major issues (so be ready for some white screens of death :D). It’s best to tread lightly ~ keep working versions of this file as an easy way back if something goes wrong. Breaking things will be how you’ll learn what works and what doesn’t ;)

SPECIFIC REQUIREMENT!! It is vital to end the code on this page without any extra empty line line breaks and NOT to add the closing PHP tag ?>

2. paste the following line at the very end of the code and save the file

!!! ensure clean line ending – no closing PHP tag ?> – no extra line breaks !!!


If you get any errors during your work with your theme – it’s always worth to check on WP forum and WP . Copy/paste the error and see how people are solving it.


May 20th, 2021 by prisca