Greetings Dear! It does not work in Joomla to put the value of a variable in a session variable and then use this value in another file, generally I do the following:

in the root directory is the file index.php, in it I get the value from the geth parameter with the following code:

$token = JRequest::getVar('_hm_token'); 

And this is the only thing that I do. Then nothing happens:

In this same index.php I try to put the value of the $token variable into the session:

 $session = JFactory::getSession(); $session->set('_hm_token', $token); 

Then I try to get the value of this session variable in $ tokenSess already in another file, which is components / com_jshopping / controllers

  $tokenSess = $session->get("_hm_token"); 

to send this value in a get parameter via this code

 file_get_contents("http://track.lead-r.ru/?method=reportAction&transaction_id=".$order->order_number."&advertiser_id=15066&offer=15066A7lMr&token=".$token); 

Tell me how to be.

  • First you need to specify the version. Then it would be necessary to specify exactly where you do it all, in the model or controller. - Dmitry Gvozd

1 answer 1

Here is an example of how to work with such things.

In the model with which you work, there should be a populateState method populateState Here is his example for version 3.0+

 public function populateState() { $number = $this->getUserStateFromRequest($this->context.'.filter.number', 'filter_number', ''); $this->setState('filter.number', $number); } 

In this method, we get data from the current user, and save.

Next we need to get them in some method, for example in the method of building a database query.

 $filter_number = $this->getState('filter.number'); 

In the view we can get our saved value by code.

 $this->state->get('filter.number'); 

By passing the state object to the template in the display method, for example.

 $this->state = $this->get('State');