0

I am updating Joomla component to Joomla 3x but getting error on code.

Code Line:

$postData = $this->dr_parameters->app->session->get('errorPostData', array() );

Error:

0 Call to a member function get() on null

and

I replaced the

previous code:

JRequest::get('post');

with

This code:

JFactory::getApplication()->input->get('post');

is this correct?

  • 1
    It depends on what $this->dr_parameters->app->session is. If $this->dr_parameters->app->session is returning a JRequest object then you need to get whatever populates $this->dr_parameters->app->session to populate it with the new object from JFactory::getApplication()->input. Or just change that line to $postData = JFactory::getApplication()->input->get('errorPostData', array());. Did that not work? – Drew G Sep 8 '17 at 19:20
0

Try using the JSession class to get the session data. Change this line:

$postData = $this->dr_parameters->app->session->get('errorPostData', array() );

to:

$objSession = JFactory::getSession();
$postData = $objSession->get('errorPostData', array());

To set a session the value of a session variable, you can do this:

$objSession = JFactory::getSession();
$objSession ->set($key, $value);
  • how can set set session, in previous code i am using this code $this->dr_parameters->app->session->set($key, $new_state); @itoctopus – Raa Hul Sep 11 '17 at 9:02
  • I have updated the answer to include setting a session variable. – itoctopus Sep 11 '17 at 9:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.