This is an archived forum post. The information may be outdated. Contact us if you have any questions.

Generating PDF while using cookies.

Ryan wrote on 2017-10-26:
We've got pages that are generated through cookie data. With that being said, it seems that the normal method of $client->getUrl() doesn't support requesting cookie data. I know there is this tool out there that does work with requesting cookie data but I'm not sure if this supports this or not. I've seen some threads about being able to get a PDF out of $client->convertHTML() which does work from what I've tested (minimal stuff). I've also read that you are able to send through CSS/images/etc. by making sure that the absolute url is brought with the HTML data, if so, does it then apply all of the styles/etc. to the page like it normally would because that should be able to suffice if there isn't an option to get the cookie data along. Thanks!
support wrote on 2017-10-27:
1/ Our new API supports cookies with the setCookies() method. You can learn more here:

2/ You can refer to external resources either via a public absolute URL or you can zip the resources together with the main document and use convertFile()
Ryan wrote on 2017-10-30:
Perfect, I've got just about everything setup. I'm a little confused on whether or not I can send multiple cookies through with the $client->setCookies() method. I'm assuming it's possible, but here is a demonstration of what I'm trying to accomplish. Say that there is about 3-4 cookies I need to send through, would I pass through the cookie name or the data? Something like:

$cookie = [
'example1' => $_COOKIE['example1'],
'example2' => $_COOKIE['example2'],
'example3' => $_COOKIE['example3']


Even if it's only one cookie at a time, how would I go about sending it through and have it print in the PDF? I've got the debugger activated and notice when it mentions the cookie parameter it's something like this: 'cookies = ..., length 24'. Thanks in advance!
Ryan wrote on 2017-10-30:
Just wanted to reply saying that I figured it out. The multiple cookies are fine, I just needed to take a closer look into the $client->setCookie() parameters. I didn't notice that it needed to be formatted such as 'cookiename'='cookiedata';.