Write Set-Cookie from Response Headers

How can I take set-cookie response headers from an api call and write them to the browser?

Hi @thomasbostwick,

Not exactly sure what you mean with ‘write them to the browser’, but in the settings of an API in the API connector you can set the flag ‘Capture response headers’:

This allows you for instance to save that set-cookie value for later use:

Hope this helps,

Gerbert
MVP Design

Thank you , I have tried this method. Long story short I have an API call that is taking place on the client-side that responds with two set-cookie headers. When I open developer tools I do not see the cookies present. I have also tried making the api call via javascript inside of an html element and does not work. I can see the call take place and get the desired response but no cookies are set.

Hi T, that is weird indeed. To make sure it is possible to capture the cookies I created a small test myself in which the cookies are saved and that works (see image below). Maybe you can recreate the API-call in Postman to verify whether the cookies are really in the header?

image

I have had the same problem. I can capture the cookies from the header, but they are not stored as cookies and so do not work automatically when it comes to later requests.

Hi @nebg,

A late response, but I had a look/search and it seems Bubble’s API connector does not handle Set-Cookie response headers automatically, but you can do it manually. So if you follow my examples above to capture the cookies and after that setup the API call with a header key ‘cookie’ and value ‘(captured cookie values)’, it might just work.

Hope this helps,

Gerbert
MVP Design