Thought I had found a fix, and posted in another thread about it, but it wasn’t correct, although I am on the right track I think.
For my site I’m working on locally, the URL is ‘localhost/WorstOf’. When the server fills out the $_COOKIE array, it does so with cookies with a path of ‘/WorstOf’. However, if I go the site with the URL of ‘localhost/worstof’ (note the case), it fills $_COOKIE with cookies with a path of ‘/worstof’, but WordPress is looking for cookies with a path of ‘/WorstOf’, and they don’t match.
So, the URL you type into the address bar has to match the case of the ‘siteurl’ you have setup when you configured your WordPress blog, as that is what the COOKIEPATH define is made from. If your ‘siteurl’ is ‘/MySite’, then you must put ‘/MySite’ in the address bar. ‘/mysite’ will take you to your site, but WordPress will look for cookies with a path of ‘/MySite’, and will always be empty.
So, you actually get logged on, but the blog can’t detect it if your address and ‘siteurl’ don’t match. But then what happens, is when you ignore the error and go about your business, behind the scenes, WordPress will redirect to your ‘siteurl’, and then the cases match up again, and all is well with the world.
So, what we need to do is detect this mismatch and redirect from the get-go. Here’s what I did.
In wp-blog-header.php, I added the following code at line 18 between
require_once( dirname(__FILE__) . '/wp-config.php');
and
wp();
(code to insert)
if($_SERVER['REQUEST_URI'] != COOKIEPATH)
{
wp_redirect(get_option('siteurl'));
exit();
}
I use COOKIEPATH because it is built from ‘siteurl’ and is exactly what I need to check the current URL against. I put it in wp-blog-header.php because index.php is the only file to include it and we only need to catch this mismatch at the first entrance to our site, and the site will then use the proper case for the rest of the session.
Once I did this, all my problems went away. I haven’t done full on extensive testing of every single feature of the site, but so far this has served me well and has shown no ill-effects. Any combination of case in my url will now work (‘/WoRsToF’, ‘/worSTof’, ‘/WORSTof’, etc…)
Anyone who sees a problem with this, or can find a better place to put such a check, or even a better solution outright, please let us know. But for now, I think this will help out some of you having the same problem I did.