Welcome Guest, Not a member yet? Register   Sign In
Error on $ci =& get_instance();
#2

[eluser]xwero[/eluser]
The language class is loaded before the CI instance exists, that is why you get the error.

I would do what you want with a post_controller_constructor hook function
Code:
function cookie_language()
{
   $CI =& get_instance();

   if(isset($_COOKIE['language']))
   {
      // check here if the cookie has a valid value
      $CI->config->set_item('language',$_COOKIE['language']);
   }
   else
   {
      setcookie('language',$CI->config->item('language'),1447);
   }
}

I have a few questions :
Where do the functions get_cookie and set_cookie come from?
Why do you need to set the $language variable after you set a cookie?
And why do you load a language file in the constructor?


Messages In This Thread
Error on $ci =& get_instance(); - by El Forum - 03-14-2009, 07:59 AM
Error on $ci =& get_instance(); - by El Forum - 03-14-2009, 08:18 AM
Error on $ci =& get_instance(); - by El Forum - 03-14-2009, 08:47 AM
Error on $ci =& get_instance(); - by El Forum - 03-14-2009, 08:55 AM
Error on $ci =& get_instance(); - by El Forum - 03-14-2009, 10:13 AM
Error on $ci =& get_instance(); - by El Forum - 03-14-2009, 11:41 AM
Error on $ci =& get_instance(); - by El Forum - 03-14-2009, 08:19 PM



Theme © iAndrew 2016 - Forum software by © MyBB