Cookies not working in Workers playground

I just tried the A/B Testing recipe provided at A/B testing with same-URL direct access · Cloudflare Workers docs
and it seems like cookies don’t work in the playground?

I only changed this:

- url.pathname = `/${group}${url.pathname}`
+ url.pathname = `${url.pathname}?${name}=${group}`

And made some requests to http://scooterlabs.com/echo
but it’s like the Set-Cookie never happens… the only thing in the cookie is __cfduid

Anyone has an idea why this is happening?

@dan42 Hello! Cookies are not meant to work on the playground. Have you tried setting the cookie from an actual Cloudflare Worker?

@irtefa Ok, I tried creating a real Worker, but when I tried to add an “On” route I got “An unknown error occurred.” (with url https://www.animenewsnetwork.com/foobar)

Note that adding an “Off” route works.

Hi @dan42! What route did you want to set “On” for? If you get the same error it would be awesome if you could share a screenshot of the error from the developer console.

Here’s the error I described:

Hi @dan42! Thanks for your patience. This should be fixed now. Can you please try creating a route?

@irtefa Indeed it works now.

Also I’ve confirmed that cookies work as expected when a worker is active in production.

BUT cookies do not work within the script editor. Maybe that’s as expected but it definitely makes testing harder. And it comes as somewhat of a surprise since it’s not mentioned anywhere in the docs.

1 Like

@dan42 noted. Thanks! We will add this information to the docs!

1 Like

Is it possible to remove __cfduid cookie when returning resources from Worker.

I am using Cloudflare worker to Server Push javascript files, but its adding __cfduid cookie to the response, as a result browser ignores the pushed resources and issues duplicate requests to download files again.