Set cookies in settings using PHP

I would like to print a document using PDFreactor using PHP.

Unfortunately, document generation is not performed when cookies are specified in the configuration. Leaving the cookie line, it prints our login page - with the correct one, since the login screen is displayed on the page if no session cookie was found.

$config = array(
    "document"=> "http://localhost",
    "logLevel"=> LogLevel::DEBUG,
    "javaScriptMode" => JavaScriptMode::ENABLED_TIME_LAPSE,
    "enableDebugMode" => true,
    "cookies" => array("sid" => "abcdefghijklmno")//<-- problematic line
);

Can someone verify that the cookie transfer failed with PHP, or give advice on the correct syntax?

+4
source share
1 answer

The problem is caused by a configuration syntax error in your cookie. The correct syntax is:

$config = array(    
    "document"=> "http://localhost",
    "logLevel"=> LogLevel::DEBUG,
    "javaScriptMode" => JavaScriptMode::ENABLED_TIME_LAPSE,
    "enableDebugMode" => true,    
    "cookies" => array(
        array("key" => "sid", "value" => "abcdefghijklmno") // <-- corrected
    )
);

For multiple cookies:

"cookies" => array(
    array("key" => "cookiename1", "value" => "cookievalue1"),
    array("key" => "cookiename2", "value" => "cookievalue2")
)
0
source

Source: https://habr.com/ru/post/1619334/


All Articles