Welcome Guest, Not a member yet? Register   Sign In
Can not set or fetch cookie
#1

[eluser]freshface[/eluser]
The code:

Code:
function switcher($id)
    {
       $this->load->helper('cookie');
       // set the cookie
       $cookie = array(
                          'name'   => 'lang_id',
                          'value'  => $id
                      );
      
       set_cookie($cookie);
        
        var_dump(get_cookie("lang_id"));
        
    //    redirect();
    }


Any ideas?

ps: I work local.
#2

[eluser]TheFuzzy0ne[/eluser]
That's not the right function for what you're trying to do. You should be using the [url="http://ellislab.com/codeigniter/user-guide/libraries/sessions.html"]sessions[/url] library for that.
Code:
$this->session->set_userdata('lang_id', $id); // Sets the data

$lang_id = $this->session->userdata('lang_id'); // Gets the data
Hope this helps!




Theme © iAndrew 2016 - Forum software by © MyBB