Cookies not working in Workers playground

workers

#1

I just tried the A/B Testing recipe provided at https://developers.cloudflare.com/workers/recipes/a-b-testing/
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?


Cloudflare Workers Beta Feedback
#2

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


#3

@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.


#4

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.


#5

Here’s the error I described:


#6

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


#7

@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.


#8

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