CodeIgniter Forums
Need help in redirect page standing - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Need help in redirect page standing (/showthread.php?tid=2324)



Need help in redirect page standing - El Forum - 07-29-2007

[eluser]java[/eluser]
Hi everybody! I have made 2 set of language, my problem is when i want to change the current language into another language : it's always back to main page (because i have created a controller named lang and this is its code:
Code:
class Lang extends Controller {
    
    function Lang()
    {
        parent::Controller();
    }
    
    function index()
    {
        $cur_lang = $this->uri->segment(3);
        if ($cur_lang=='english' OR $cur_lang=='vietnamese'){
            $cookie = array(
                   'name'   => 'lang',
                   'value'  => $cur_lang,
                   'expire' => '86500',
                   'domain' => $this->config->item('cookie_domain'),
                   'path'   => '/',
                   'prefix' => '',
               );
            set_cookie($cookie);
            redirect('/home', 'refresh');
        }else{
            redirect('/home', 'refresh');
        }
    }
}
), i want when i standing on the current page(not main page) and change language, it's still stand on that page and not back to main page. How can i solve this problem? Thanks for any response.


Need help in redirect page standing - El Forum - 07-30-2007

[eluser]Michael Wales[/eluser]
Store a cookie/session variable for every page they visit (except for pages within the Lang controller). Update that cookie/session with the entire URI (controller/method/params).

Then just change you redirects there to pull the value of that cookie/session down for their first param.