WordPress Development Asked by Zeth on October 26, 2020
How do I get the contents of the PHP-variable: COOKIEHASH
inside a Cypress-test.
I’m writing some Cypress-test for WordPress, and in order to set the cookies to log in a user in WordPress using Cypress, then I need the contents of the COOKIEHASH
-variable.
For those not familiar with the COOKIEHASH
, go to a WordPress-installation and put in this code anywhere:
echo '<pre>';
print_r(COOKIEHASH);
echo '</pre>';
die();
And then you’ll see it. It looks something like this: a8b94154380982c3284a467b8aa224c6
.
When I run my Cypress-tests for the first time, then I don’t know what that hash is, so I don’t know which cookies to set.
So currently I log in manually, go to cookies in my browser and get the hash. Which is quite the manual operation for automated tests. 🙂
If I hash zeth.dk
, then the js-md5-hash gives me: 8aa4b9bbc2a9e946b670fd8372a3081a
and I can see in my cookies that the hash is: b7d8d5a26884619e3b3b4481ba778642
By default it's the MD5 hash of the site URL:
$siteurl = get_site_option( 'siteurl' );
if ( $siteurl ) {
define( 'COOKIEHASH', md5( $siteurl ) );
}
This includes the scheme but not a trailing slash, so in your example you'd need the hash of https://zeth.dk
.
You can also override this by defining COOKIEHASH in wp-config.php with some other value.
Correct answer by Rup on October 26, 2020
1 Asked on November 16, 2021 by maheshwaghmare
0 Asked on November 16, 2021 by kelvin-ramirez
0 Asked on November 14, 2021
1 Asked on November 14, 2021 by dalton-rooney
1 Asked on November 14, 2021 by scorman
1 Asked on November 14, 2021 by zackakai
child pages custom post types next post link pagination previous post link
10 Asked on November 11, 2021
1 Asked on November 11, 2021 by syntacular
2 Asked on November 11, 2021 by pukka
2 Asked on November 11, 2021 by northtime
3 Asked on November 11, 2021 by nicautre
1 Asked on November 11, 2021 by abhivemp
0 Asked on November 11, 2021 by bluedimensional
0 Asked on November 11, 2021 by stuart-kushner
1 Asked on November 11, 2021 by artist-learning-to-code
Get help from others!
Recent Questions
Recent Answers
© 2023 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP