Are PDFReactor cookies HttpOnly?

149 Views Asked by At

I'm trying to pass cookies from PHP to the rendered webpage.

My configuration is:

$config = array(

            "logLevel"=> \LogLevel::DEBUG,
            "javaScriptMode" => \JavaScriptMode::ENABLED_REAL_TIME,
            "enableDebugMode" => true,
            "cookies" => array(
                array(
                    "key" => "sid",
                    "value" => "abc"
                ),
                array(
                    "key" => "soid",
                    "value" => "def"
                )
            )
        );

But when I try to access the cookies via document.cookie, the property is empty.

Any suggestions?

1

There are 1 best solutions below

2
On

Cookies that are specified in the configuration are automatically send by PDFreactor each time it opens a HTTP or HTTPS connection to e.g. request resources or perform AJAX calls in JavaScript. They currently are not added to the "document.cookie" property.

Do you have any specific use case for this or are you simply trying to make data from your PHP integration accessible in the document's JavaScript during conversion? In the latter case, you could add a user script to your configuration that includes the cookie data like this:

$config = array(
    // ...
    "userScripts" => array(
        array(
            "content" => "var myCookies = { sid: 'abc', soid: 'def' }",
            "beforeDocumentScripts" => true
        )
    )
);

You can now access the cookies from within JavaScript via the "myCookies" property.