Skip to content
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

how to get cookies from jar #912

Closed
ralyodio opened this issue May 25, 2014 · 3 comments
Closed

how to get cookies from jar #912

ralyodio opened this issue May 25, 2014 · 3 comments

Comments

@ralyodio
Copy link

How do I get the cookies from the cookie jar?

jar.cookies is undefined

    var jar = request.jar()
    request = request.defaults({jar: jar });
@albinekb
Copy link

I do it the "hacky" way, jar._jar.store.idx[validUrl]
Don't know what the right way to do this, but it works.

Looking at test-cookies.js it uses jar.getCookieString(validUrl) which seems to be the right way to get cookies (?) This depends on tough-cookie being installed.

Related to #884

@charlespwd
Copy link
Contributor

tough-cookie is already part of request. You can access the cookie string (e.g. "TEST=1; SESSID=14;") via

var j = request.jar();
// ...
cookies = j.getCookieString(url); 

But I'd like a better way to parse them into objects. Doesn't seem too hard to parse them.

@FredKSchott
Copy link
Contributor

You'll want to use jar.getCookies()
Check out lib/cookies.js for more info about the RequestJar object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants