Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

language in codeigniter doesn' t work as expected

I have a web site with two languages, it works in localhost perfect. but when I run it on a production enviroment and people try to change the language doesn't work, they need to press F5 key in the browser,so then the site reload in the language they choose. Any idea?? Thanks...

public function __construct()
    {
        parent::__construct();     
        $this->lang->load('navmenu', $this->session->userdata('language'));
        $this->lang->load('search', $this->session->userdata('language'));
        $this->lang->load('home', $this->session->userdata('language'));
    }

/.../
function ChangeLanguage ($lang)
    {
        $this->session->set_userdata('language', $lang);
        redirect(base_url());
    }

  anchor('lang/changelanguage/spanish','Español')  
   anchor('lang/changelanguage/english','English')
like image 436
Luis Lopez Avatar asked Nov 28 '25 14:11

Luis Lopez


1 Answers

to debug this in production server, you can temporary put

error_reporting(E_ALL);

and see what other errors are there that prevents the proper redirecting. You also should check the response headers being sent by your production server. Does it have "cache", does it need re-validate header, etc

like image 69
fedmich Avatar answered Nov 30 '25 05:11

fedmich



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!