amplitude / experiment-php-server

Amplitude Experiment PHP Server SDK

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

gfirem opened this issue · comments

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

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.

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