WordPress Logged-in Cookie Problem and Solution

|

My WordPress blog is installed in a subdirectory in my document root. This keeps the document root tidier. The problem is that the cookie titled “wordpress_logged_in_somerandomhash” that tells WordPress you’re logged has its path set to http://www.yoursite.com/subdirectory. You can still log into the admin console. But when you visit your blog at http://www.yoursite.com, WordPress doesn’t think you’re logged in because your browser doesn’t send the wordpress_logged_in_somerandomhash cookie.

This is not a huge problem, but I wanted that nice banner on the top that allows me to have admin functions. I also wanted each post to have an “edit” link for easy editing.

Figuring this out took me all afternoon. The solution is to define “COOKIEPATH” in your config.php file. Just add define('COOKIEPATH', '/'); to the beginning of config.php.