CodeIgniter Forums
Switch Language - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Switch Language (/showthread.php?tid=67485)



Switch Language - eagle00789 - 02-27-2017

I'm turning my current english only site to a multi-lingual site (currently LtR only, but RtL comming at a later date), but i hit one small snag.
My current language switching method is using a route. the url that the user follows is 'settings/SetLanguage/english'
After the language switch, the user is back at the index page. How can i make sure the user is back at the page it switched the language on.


RE: Switch Language - eagle00789 - 02-27-2017

I'm going to answer my own question here.

In my SetLanguage route i added the following line as last line
PHP Code:
redirect($this->session->current_url); 

In my controller(s) i just add the following line to the constructor
PHP Code:
$_SESSION['current_url'] = $this->uri->uri_string(); 
And my problem is completely solved. Cool