1

My home page url looks like this

http://localhost/mediabox/home/box/12

I have a link of language on home page when a user clicks on that link i am sending that language id as query string , the page reloads and the url converts to

http://localhost/mediabox/home/box/?bid=12&ln=2

I want to reload the page with the new language but don't want to change my url i-e I want my URL to be

http://localhost/mediabox/home/box/12

after the page loads

How it is possible please me some gud ideas Thanks

7
  • Are you using a php framework? Commented Mar 21, 2012 at 15:05
  • @safarov yes i m using codeigniter Commented Mar 21, 2012 at 15:06
  • The link looks like this <a href="<?php echo base_url(); ?>home/box/?bid=12&ln=2"> where bid and ln are dynamic Commented Mar 21, 2012 at 15:08
  • 3
    Just set a language cookie. Then the language is not dictated by the URL. For example, when the user clicks the language link, setcookie('ln', 2); and when you get a page request you can check $_COOKIE['ln'] for the language to use. Commented Mar 21, 2012 at 15:08
  • @DaveRandom Can u ply provide me some basic sudo code I m using codeigniter with a controller and view Commented Mar 21, 2012 at 15:11

1 Answer 1

1

VIEW

<a href=<?php echo site_url('home?language=indonesian');?>>Indonesian language</a>

CONTROLLER

class Home extends CI_Controller {

    public function index()
    {
        $language = $this->input->get('language');
        if($language){

            // Put your code here

            // Now u can set session
            $this->session->set_userdata('language', $language);
            redirect('home');
        }

        if($this->session->userdata('language'))
        {
            var_dump($this->session->userdata('language'));
        }
        echo 'Hello World!';
    }

}
Sign up to request clarification or add additional context in comments.

1 Comment

The language is still shown in the url and if i redirect to home page the changes dont take place

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.