Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The cookie name generate is not matching the one from the frontend client #23

Closed
gfirem opened this issue Jun 5, 2024 · 2 comments
Closed

Comments

@gfirem
Copy link

gfirem commented Jun 5, 2024

Hello.

I'm using this code example https://www.docs.developers.amplitude.com/experiment/sdks/php-sdk/#access-amplitude-cookies to get the cookie from the client library, and the backend PHP code is not generating the correct cookie name.

image

@bgiori
Copy link
Collaborator

bgiori commented Jun 5, 2024

Hi @gfirem, thanks for submitting this issue.

Are you passing the newFormat field as true in the AmplitudeCookie::cookieName, AmplitudeCookie::parse, and AmplitudeCookie::generate functions?

Based on the screenshot you provided you're using the analytics-browser (new) SDK which means you will need to set the newFormat option to true in those functions.

Finally, the analytics-browser sdk sets a number of additional cookie options like domain, samesite, etc.

I'd recommend looking at amplitude cookie in your debugger and coping all the options into the set-cookie response header when generating a new cookie so the SDK does not create multiple cookies with the same name but different options and values.

@gfirem
Copy link
Author

gfirem commented Jun 6, 2024

I will close the issue, my mistake was to use the deployment key instead of the project api key. Thanks for your help @bgiori

@gfirem gfirem closed this as completed Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants