Skip to content

Loading…

Retrieve cookies from server response #379

Closed
spiffytech opened this Issue · 7 comments

6 participants

@spiffytech

How can I retrieve the cookies returned by the server I call out to with request?

@jmnunezizu

You can use your own jar and then read them, i.e.

var jar = request.jar();
request({
jar: jar
});

console.log(jar.cookies);

@chovy

I'm getting undefined when I do jar.cookies

@lalitkapoor
request member

you could take a look at the response's headers for Cookie res.headers i believe. Alternatively you could use jar.getCookieString(YOUR_URL_HERE)

@kildem

this is how I retrieve cookies: receiveCookie = response.headers['set-cookie'][x]
then I use cookie = toughCookie.Cookie.parse(receiveCookie)
and jar.setCookie(cookie ....
this works form me :)

@chovy

thanks. i think jar.setCookie will take the original receiveCookie though? or am i wrong about that.

@kildem

yes, but I need to parse "receiveCookie" in other to get things work ... this is the solution I found

@mikeal
request member

Is this still an issue?

This is so old I'm closing, if it is actually still an issue just let me know and I'll re-open.

@mikeal mikeal closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.