Title: Login Cookie Issues
Last modified: August 21, 2016

---

# Login Cookie Issues

 *  [jrshor](https://wordpress.org/support/users/jrshor/)
 * (@jrshor)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/login-cookie-issues/)
 * I have the PHP code posted in the header of my theme. When I first open my browser
   and try to login, it redirects me to the login page and says “ERROR: Cookies 
   are blocked or not supported by your browser. You must enable cookies to use 
   WordPress.” After I enter my login information again, it logs me in a redirects
   me to my website. This only happens after I try to login for the first time since
   opening my browser. I’ve tried logging in on several different browsers on my
   computer, as well as other computers. Any reason for this? My site is [http://upmc.coop/test/](http://upmc.coop/test/)
 * [http://wordpress.org/plugins/wp-login-box/](http://wordpress.org/plugins/wp-login-box/)

Viewing 7 replies - 1 through 7 (of 7 total)

 *  [vnairp11](https://wordpress.org/support/users/vnairp11/)
 * (@vnairp11)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/login-cookie-issues/#post-4278988)
 * I am having the same issue on my site im running the latest 3.7 version of wordpress
   please help thanks.
 *  [Be Dark](https://wordpress.org/support/users/b_dark/)
 * (@b_dark)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/login-cookie-issues/#post-4279035)
 * same problem with wp 3.8
 *  [origamifreak2](https://wordpress.org/support/users/origamifreak2/)
 * (@origamifreak2)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/login-cookie-issues/#post-4279043)
 * Same problem with wordpress 3.8 Would appreciate a fix 🙂
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/login-cookie-issues/#post-4279044)
 * **[@origamifreak2](https://wordpress.org/support/users/origamifreak2/)**: If 
   you require assistance then, as per the [Forum Welcome](http://codex.wordpress.org/Forum_Welcome#Where_To_Post),
   please post your own topic.
 * This topic references an old version of WordPress.
 *  [origamifreak2](https://wordpress.org/support/users/origamifreak2/)
 * (@origamifreak2)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/login-cookie-issues/#post-4279047)
 * I found a solution to this problem on [this page](http://wordpress.org/support/topic/cookie-error-when-logging-in?replies=117).
   It seems to be a problem with how the newer versions of WordPress test for cookie
   support. There’s several examples of code to fix the problem in the comments.
   The code I used was from Cam on the second page. To make it work for the plugin
   I just modified the “add_action()” parameters to be “add_action( ‘init’, ‘set_wp_test_cookie’);”
   and then pasted it in plugin.php right above the rest of the functions on about
   line 107.
 *     ```
       function set_wp_test_cookie() {
       	setcookie(TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN);
       	if ( SITECOOKIEPATH != COOKIEPATH )
       		setcookie(TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN);
       }
       add_action( 'init', 'set_wp_test_cookie');
       ```
   
 *  [hillslope](https://wordpress.org/support/users/hillslope/)
 * (@hillslope)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/login-cookie-issues/#post-4279055)
 * Origamifreak
 * Sorry, not code savvy. Do you paste the full code you have there into the plugin.
   php file for this wploginbox plugin?
 * Does it need to be before all functions, or just after the if user logged in 
   function?
 *  [Robin Hislop](https://wordpress.org/support/users/tramuntana/)
 * (@tramuntana)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/login-cookie-issues/#post-4279077)
 * For anyone having this problem, I found the easiest solution was to include the
   following in my themes functions.php:
 *     ```
       function set_wp_test_cookie() {
       	setcookie(TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN);
       	if ( SITECOOKIEPATH != COOKIEPATH )
       		setcookie(TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN);
       }
       add_action( 'after_setup_theme', 'set_wp_test_cookie');
       ```
   

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Login Cookie Issues’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/wp-login-box_f4f4f4.svg)
 * [WP Login Box](https://wordpress.org/plugins/wp-login-box/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-login-box/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-login-box/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-login-box/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-login-box/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-login-box/reviews/)

## Tags

 * [cookies](https://wordpress.org/support/topic-tag/cookies/)
 * [login](https://wordpress.org/support/topic-tag/login/)

 * 7 replies
 * 7 participants
 * Last reply from: [Robin Hislop](https://wordpress.org/support/users/tramuntana/)
 * Last activity: [11 years, 10 months ago](https://wordpress.org/support/topic/login-cookie-issues/#post-4279077)
 * Status: not resolved