How to define a dynamic global variable in code-igniter framework.
I am using Geo-Location tracking api, which tracks the country of the user based on user's IP address. I need to set the value of this global variable dynamically depending on the country code returned from the API.
what is the best way to achieve this ?
In your case, You can store the value in session like this
$newdata = array(
'country' => 'Nepal',
);
$this->session->set_userdata($newdata);
And again retrieve the session value like this
$country = $this->session->userdata('country');
Have a look at their website (see the Config Class), it is written in great detail there.