Forum Replies Created

Viewing 1 replies (of 1 total)
  • Hi, I had the same problem. In my case, the problem was that I was accessing the website as “mydomain.com/passwordprotpost”, but the domain of the cookie (containing the password for the page) was set to “www.mydomain.com”. As a result, the cookie to give me access to the password protected page wasn’t being sent by my browser to the website, resulting in the behavior of me entering the correct password, but still being sent to the page to enter the password for the page.

    I hacked up a solution so that the cookie is set with the correct domain, i.e., with the domain “.mydomain.com”. This means that the cookie can be served up to either the mydomain.com, or https://www.mydomain.com. There is probably a more elegant solution, but I’m new to wordpress.

    The solution I used was to edit the file wp-pass.php. This contains code that sets the cookie for the password protected page. I changed the line

    setcookie('wp-postpass_' . COOKIEHASH, $_POST['post_password'], time() + 864000);

    to be

    setcookie('wp-postpass_' . COOKIEHASH, $_POST['post_password'], time() + 864000, COOKIEPATH, preg_replace('|https?://(www)?|i', '', get_settings('home') ));

    After doing this, the password protected page worked whether I accessed it as “mydomain.com/passwordprotpost” or “www.mydomain.com/passwordprotpost”

Viewing 1 replies (of 1 total)