Hi,
I am converting HTML to pdf through wkhtmltopdf library, here session is behaving very differently that if we set the session when our link is called then it works fine but our previously set session is not getting?
exec('C://"Program Files"//wkhtmltopdf.exe ' . 'http://localhost/test.php?a=351' . ' ' . $file_name . '');
Problem:
Session set in test.php is available in this page when printing the page. But if we set the session in some previous page i.e test2.php then that value is null here in test.php
Is any idea?
Because it's how sessions works, wkhtmltopdf.exe creates another session, another connection to your script, and it's normal that you won't get values from another session.
You can pass variables as get parameters via GET or, you can store them in some permanent location, like file or database.
Though answered is already accepted and its little late, I am still adding the answer to help other just for reference. Using session id we can create the pdf from html.
Command is
wkhtmltopdf --cookie 'sessionid' 'typpotvp1ha1mdssvnfg548yhkwo5j4q' 127.0.0.1:8000/posts/report ./report.pdf
来源:https://stackoverflow.com/questions/11896726/session-issue-in-wkhtmltopdf