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

Added ability to specify cookies #52

Closed
wants to merge 3 commits into from

Conversation

green-arrow
Copy link

Using a .JSON file (see cookies.json), you can attach cookies to the
phantom page request. This will allow you to capture pages that are
behind a login wall.

An issue exists for this at: #41

Using a .JSON file (see cookies.json), you can attach cookies to the
phantom page request. This will allow you to capture pages that are
behind a login wall.
@sethvoltz
Copy link

Very useful for ensuring apps that are only visible post-login still work at common resolutions. +1

@sindresorhus
Copy link
Owner

Sorry about the delay. Vacation and stuff.

I agree this is needed, but I'm not sure I agree with the implementation.

How about just an option flag:

pageres todomvc.com 1400x000 --cookie 'value1; value2; name1=value1'

where the value is just a normal cookie or multiple.

Thoughts?

@sindresorhus
Copy link
Owner

// @8bitDesigner

@8bitDesigner
Copy link

I like both approaches, however if you do need to specify things like the cookie domain (all our sites share a cookie on *.company.tld, for example), the commandline approach, while cleaner, doesn't seem to allow that.

@sindresorhus
Copy link
Owner

Yes, it does:

pageres todomvc.com 1400x000 --cookie 'reg_fb_gate=deleted; Expires=Thu, 01-Jan-1970 00:00:01 GMT; Path=/; Domain=.example.com; HttpOnly'

@8bitDesigner
Copy link

Oh, I do like that format, then. document.cookie style gets my vote.

@green-arrow
Copy link
Author

With this approach, it seems like you'll only be able to specify one domain / path. So if you have 4 cookies, they'll all have the same domain, path, etc. Is that acceptable?

@8bitDesigner
Copy link

Could you use, say --cookie "foo=bar;" --cookie "bar=baz" and use multiple --cookie declarations?

@sindresorhus
Copy link
Owner

Yes

Instead of using a JSON file for cookies, they can just be specified on
the command line with a ‘—cookie’ flag.
@green-arrow
Copy link
Author

That is a pretty rough pass at using the --cookie flag to specify cookies. Unfortunately I don't have a whole lot of time at the moment, so it's not very pretty. I tested quickly with Charles and it looks like it puts the cookies on correctly.

@sindresorhus
Copy link
Owner

Can you fix the merge conflict? Your fork is out of date ;)

@green-arrow
Copy link
Author

Yeah, that was way out of date! Tried to clean up everything, let me know if that fixed it. Have to run at the moment so I won't be able to do any more tonight.

@sindresorhus
Copy link
Owner

@green-arrow Still interested? Needs a good rebase.

@sindresorhus
Copy link
Owner

Closing for now as a lot has changed since this PR was opened and lack of activity. Would still welcome a PR that adds cookie support according to #52 (comment).

@sindresorhus
Copy link
Owner

If anyone is still interested in getting this landed I would happy to receive another PR: #41

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

Successfully merging this pull request may close these issues.

None yet

4 participants