Session issue in wkhtmltopdf

眉间皱痕 提交于 2019-12-10 11:09:32

问题


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?


回答1:


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.




回答2:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!