httpOnly cookies are *prevented* from being accessed by client-side (e.g. 
in the browser) JavaScript. This attribute, however, has no effect when 
making a server-side HTTP request.

There are, effectively, a couple of ways to handle this (assuming, of 
course, you're making an HTTP request using server-side node)...

1. You can grab the cookie from the response headers themselves and return 
it with your next request, something along the lines of:

var cookie = get(response.headers, "Set-Cookie")if (cookie) {
  cookie = (cookie + "").split(";").shift()
  set(opts.headers, "Cookie", cookie)}


The second approach would be to use Request 
(https://github.com/request/request) which essentially does the same thing 
for cookies as the above code, though more elegantly and supports multiple 
cookies in the request, plus a lot of other things you can't get out of the 
box with Node and HTTP requests.

HTH

-- Denny


On Friday, May 27, 2016 at 9:21:40 AM UTC-4, brenda...@freshenergy.co.za 
wrote:
>
> Hi
>
> I hope someone can help me. I am new to JS and am struggling to store the 
> response httponly cookie from a server so I can send it back in my next 
> request.
>
> I know that httponly doesnt like JS, C# has a cookie container that can be 
> used to store and send the cookies. Can someone point me in the right 
> direction?
>
> I really appreciate the help!!
>

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
To post to this group, send email to nodejs@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/b261cf02-59c8-4fdb-81c7-0baeadfe4d47%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to