Repository navigation
Description
Checklist
- I have looked into the Readme and the documentation, and have not found a suitable solution or answer.
- I have searched the issues and have not found a suitable solution or answer.
- I have searched the Auth0 Community forums and have not found a suitable solution or answer.
- I agree to the terms within the Auth0 Code of Conduct.
Describe the problem you'd like to have solved
v5 appears to have removed the hooks mentioned in this issue. I am using pantheon, and need to prefix the cookie names with STYXKEY_ to avoid cookies being lost due to the CDN.
Describe the ideal solution
The ideal solution would be to add an optional field to the plugin's settings in the WordPress admin dashboard to set the SDK configuration object's storage IDs with the prefix. This would save custom work needing to be done to achieve this with the plugin.
Alternatives and current workarounds
I achieved a workaround by adding a plugins_loaded action in functions.php of my site as follows:
// change the auth0 cookie name to be prefixed with STYXKEY_ for Pantheon
function update_auth0_cookie_storage_id()
{
$auth0SDK = wpAuth0()->getSdk();
$auth0Config = $auth0SDK->configuration();
$storageId = 'STYXKEY_' . $auth0Config->getSessionStorageId();
$transientId = 'STYXKEY_' . $auth0Config->getTransientStorageId();
$auth0Config->setSessionStorageId($storageId);
$auth0Config->setTransientStorageId($transientId);
$auth0Config->setSessionStorage(new CookieStore($auth0Config, $auth0Config->getSessionStorageId()));
$auth0Config->setTransientStorage(new CookieStore($auth0Config, $auth0Config->getTransientStorageId()));
$auth0SDK->setConfiguration($auth0Config);
}
add_action('plugins_loaded', update_auth0_cookie_storage_id());I was able to update the configuration of the SDK by using this method. However, it took me a while of reading the source code of the plugin and SDK to find this solution, so I am proposing adding a setting in the Plugin settings on the WordPress admin dashboard.
Additional context
Pantheon Cache Docs for reference here.
Activity
evansims commentedon Apr 16, 2024
Hey @jaketfoster, thanks very much for the suggestion. My bandwidth is currently allocated to another project so I can't give a firm ETA, but we will get to this as soon as possible. In the meantime, your workaround solution looks excellent 👌
kishore7snehil commentedon Jun 5, 2025
@jaketfoster This is a great feature idea. W’d be happy to review a PR if you’re up for contributing.
marcelo2605 commentedon Jul 16, 2025
@jaketfoster I'm testing your suggestion on my app, also hosted on Pantheon. But I'm using just the auth0-PHP package, changing the cookie name inside
SdkConfigurationmethod.'sessionStorageId' => 'STYXKEY_auth0_session',But it's not working. I'm getting the
Invalid Stateerror. Did you need to do any additional configuration to get cookies working? For now, I'm testing on a multi-site (https://pr-22-MYPROJECT.pantheonsite.io/)marcelo2605 commentedon Jul 21, 2025
Problem fixed!
graham73may commentedon Aug 12, 2025
I was getting some warnings thrown by wp-includes/plugin.php because of the way add_action() was written in the code snippet above.
Updated:
update_auth0_cookie_storage_id()to'update_auth0_cookie_storage_id'EDIT 1:
Also incase anyone else hits this (it might just be the way my project is loading composer's autoload) but I had to change to
init:EDIT 2:
Scrap that, that broke it on Pantheon. Locally
initmakes my cookie names change but when deployed to Pantheon you don't stay logged in.Changing it just to
update_auth0_cookie_storage_id();infunctions.phpas it was firing instantly in the original example worked for me.So I've ended up with this:
if anyone knows of a better hook please do let me know...