-
Notifications
You must be signed in to change notification settings - Fork 447
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
Better way to set cookies and other repeatable headers in Javascript Http functions #2737
Comments
please provide more information (see our issue template) |
Look at this: It mentions
|
Ahh, so you're trying to do it from JavaScript? I'm not sure if this is possible right now. @mhoeger do you know? |
@cesarvarela I think I responded to your stackoverflow post :) I recommended using the HTTP header "Set-Cookie". Is there anything special about the express "cookies" method that can't be done through HTTP headers? Or would you like to see this as a feature? |
Yes you did. That would work, but I think it would be nice to make it work like the other settings, something like:
|
Sounds good. Thanks for the input! I'd imagine other developers coming from express will also expect a "cookies" property as is done there. Instead of adding a cookies property, I'm inclined to stick to the HTTP standard way of doing things with I'll re-triage this issue for now as a feature request for a |
The primary problem for me with the current approach is that it's quite difficult to set multiple cookies in one response.
|
I second @alanmartin. The current implementation is rather limited with regards to setting multiple cookies. Only with the mentioned work around, it is currently possible to set multiple cookies. The implementation suggested by @cesarvarela could be altered like this to facilitate multiple cookies: ...
res = {
status: 201,
cookies: [
{
'name': 'cookie1',
'value': value,
'secure': true,
'httponly': true,
'path': '/',
'domain': 'www.example.com',
etc..
},
{
'name': 'cookie2',
'value': value,
'secure': true,
'httponly': true,
'path': '/',
'domain': 'www.example.com',
etc..
},
],
body: "some body"
}
... |
Good point, thanks for bringing this up! Will prioritize this as more than an enhancement. Note for others the current workaround is adding white spaces as @alanmartin suggested above. |
This is also impacting us as well. We're also looking to set multiple cookies. |
I am not able to set multiple cookies correctly even with white spaces. I am getting the below error: |
I get the same. Multiple cookies is required in many circumstances, and Azure simply can't handle them. How hard can this be to implement? (answer is "not that hard") |
@gpasq - we always love and accept community contributions as an open source project :) I am starting the work to enable setting multiple cookeis here FYI all on this thread: Azure/azure-functions-language-worker-protobuf#31 |
Checking up after 6m... was this ever released? |
@dcollien Yes - sorry forgot to update the issue! You can set multiple cookies on a response object with the property "cookies", which takes an array of Cookie objects. Ex:
I'll be sure to update the docs |
I'm kind of lost here, but I don't see anything related to using cookies in the docs.
I need to write/read them, is it possible?
The text was updated successfully, but these errors were encountered: