How to pass cookie in pdfkit #135

Closed
meetme2meat opened this Issue Apr 23, 2012 · 2 comments

Comments

Projects
None yet
3 participants
@meetme2meat

I have a page which contain an iframe an if required to passed cookie inorder for wkhtmlpdf to crawl that page which instead required to pass cookie as options to pdfkit .

Now I just can seem to figure out the options to pass cookie
looking at the code #130 I expected the the methodology used in would solve but then quickly I realize there are wrong thing happen in pdfkit

passing cookie as key,value in array would result in Rails application something like this

-----------------------------{"[\"_session_id\""=>nil, "\"47ec4924ccb63d4b28205984a74361b8\"]"=>"--quiet"}-----------------

I inspected the cookie using

Rails.logger.info "---------------#{request.cookies}------------------------"

when passed as argument to standalone wkhtmlpdf

like

wkhtmltopdf --cookie '_session_id=47ec4924ccb63d4b28205984a74361b8' http://localhost:3000/ a1.pdf

everything seem to work well

same problem arises when using custom-header options with pdfkit.

@alkesh

This comment has been minimized.

Show comment
Hide comment
@alkesh

alkesh Jul 18, 2013

the following works for me:

kit = PDFKit.new(url, cookie: [cookie_name, cookie_value])

alkesh commented Jul 18, 2013

the following works for me:

kit = PDFKit.new(url, cookie: [cookie_name, cookie_value])
@sigmavirus24

This comment has been minimized.

Show comment
Hide comment
@sigmavirus24

sigmavirus24 Aug 24, 2013

Contributor

Looks like there's a solution for this and it might just need to be documented.

Contributor

sigmavirus24 commented Aug 24, 2013

Looks like there's a solution for this and it might just need to be documented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment