0

I have setup up a WordPress project from Platform sh in my local host. I get get the project by using the platform get [id] command. I Imported the database in my localhost and configured the wp-config.php file and then I have run the platform build command and the build is successful. I have also run platform mount: download to download cache and uploads folder inside wp-content folder. But when I open the site in my localhost it's not showing the pre-signon page and it's not opening /wp-admin/ page. When I open the site it's directly redirecting to the/wp-login.php/ page. And when I try to log in using my username and password it's showing below cookie error:

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

I have renamed /themes/ folder and /plugins/ folder to /themes-old/ and /plugins-old/ and tried to log in but it's still showing the same error. Here is the screenshot attached for the error:

enter image description here

14
  • 1
    Have you contacted platform.sh support? And confirmed it with a standard normal WordPress install? Your screenshot has styling that is not standard WordPress and non-standard functionality. There's not enough information to debug the problem in your question
    – Tom J Nowell
    Jun 1, 2023 at 12:54
  • Actually, I imported the database of the live site into my local host and tried to run the project. Then I tried to log in with the same admin credentials as in my live site but it's showing the above cookie error. I don't think there is any mistake about platform sh. I have also set up another similar website from platform sh in my local host and it is working fine. I searched for the above error in my code files and this message is present in my WordPress default wp-login.php file. And then I checked the wp-login.php file of fresh WordPress installed and this message is also present there.
    – tek bhatt
    Jun 2, 2023 at 9:58
  • } elseif ( isset( $_POST['testcookie'] ) && empty( $_COOKIE[ TEST_COOKIE ] ) ) { // If cookies are disabled, the user can't log in even with a valid username and password. $user = new WP_Error( 'test_cookie', sprintf( /* translators: %s: Browser cookie documentation URL. */ __( '<strong>Error:</strong> Cookies are blocked or not supported by your browser. You must <a href="%s">enable cookies</a> to use WordPress.' ), __( 'wordpress.org/documentation/article/cookies/…' ) ) ); }
    – tek bhatt
    Jun 2, 2023 at 9:58
  • This code is present in the wp-login.php file for all the WordPress sites by default.
    – tek bhatt
    Jun 2, 2023 at 9:59
  • then it's extremely likely the cause is that your URLs mismatch between local and production and you have forgotten to perform a search replace, and that is why you're getting this issue, because WP cannot set a cookie for the production domain. If it did work then it's likely WP would have redirected you instead to the production site
    – Tom J Nowell
    Jun 2, 2023 at 10:15

2 Answers 2

0

Putting the code below in the settings.php file to boycott cookies solved my issue.

define( 'AUTH_KEY',         'put your unique phrase here' );
define( 'SECURE_AUTH_KEY',  'put your unique phrase here' );
define( 'LOGGED_IN_KEY',    'put your unique phrase here' );
define( 'NONCE_KEY',        'put your unique phrase here' );
define( 'AUTH_SALT',        'put your unique phrase here' );
define( 'SECURE_AUTH_SALT', 'put your unique phrase here' );
define( 'LOGGED_IN_SALT',   'put your unique phrase here' );
define( 'NONCE_SALT',       'put your unique phrase here' );

define('ADMIN_COOKIE_PATH', '/');
define('COOKIE_DOMAIN', '');
define('COOKIEPATH', '');
define('SITECOOKIEPATH', '');
0

In your wp-config.php file, you need to make sure WP_HOME and WP_SITEURL are set for your local environment. How you do that will depend on what you are using for your local development. I would suggest using DDEV or Lando as Platform.sh has integrations for both. DDEV, Lando. Combine them with the wp-config.php file from one of Platform.sh's WordPress templates, and it should just work without any additional changes on your part.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.