Welcome Guest, Not a member yet? Register   Sign In
cookies doesnt work
#1

With Codeigniter i try to set cookies, but when i want to retrieve the cookies with var_dump, i will get bool(false), also if i want to check the cookes with google chrome's inspector, none of the cookies are set.

I am trying to set a cookie when a user logs in and checks a checkbox for remembering him on his computer. In my controller i have the following code for setting the cookie:

if($this->input->post('remember_me_checkbox')){
$this->load->helper('string');

$randomString = random_string('alnum', 16);

$cookie = array(
'name' => 'rememberme',
'value' => $randomString,
'expire' => '1209600', // Two weeks
'domain' => '.ecalik.nl',
'path' => '/'
);

$this->input->set_cookie($cookie);

$data = array(
'remember_me_token' => $randomString
);
but now if i want to retrieve the cookie: $data['cookie'] = $this->input->cookie('remember_me_token', TRUE);

then it doesn't work. Please help if possibleSmile
Reply
#2

You are trying to get a cookie that you didn't define. You should get it with:
PHP Code:
$this->input->cookie('rememberme'); 
 
...and not with 'remember_me_token'.
Reply
#3

I already fixed it, the domain had to be '' because i was on localhost < stupid beginner mistake Big Grin
Reply




Theme © iAndrew 2016 - Forum software by © MyBB