KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Getting error when tried to get session data in codeIgniter #801

Open Keerthiga opened this topic on on Apr 12, 2019 - 2 comments

Keerthiga commented on Apr 12, 2019

Hi, I need to get current logged in users data. So, i tried to get userId in my Report.php file i have got below error. Trying to get property '$this' of non-object

application/report/Report.php i have added the below code to get session data

$this->session->userdata('logged_in');

Please advise us how to load session variable into report file using codeIgniter. Thanks.

KoolReport commented on Apr 12, 2019

It is better that you get the current user login outside of the report and transfer that user id as the parameter for report. As in the report, the term "$this" could refer to report, not the controller of CodeIgniter anymore. Do this:

$report = new MyReport(array(
    "userId"=>$this->session->userdata('logged_in')
));

and then in the report you can get the user id like this:

$this->params["userId"]

Hope that helps.

P/s: Sorry that I changed the tag of topic to "Help needed", please use the tag "Bug" if you found a bug in KoolReport core. If there is case of unsure, you use "help needed" first and when confirm it is bug in koolreport, you can mark with bug. Thank you very much :)

Keerthiga commented on Apr 12, 2019

Thanks

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed

CodeIgniter