Welcome Guest, Not a member yet? Register   Sign In
Why aren't my cookies writting?
#13

[eluser]Learn CodeIgniter[/eluser]
You cannot pass TRUE in the second parameter it is expecting a string value and you need to use the time function to get the current time and then add the amount of time to it. With the die your cookie will always fail because it has not been written yet until the next page refresh.
Code:
function login()
{
  $this->input->set_cookie("loggedin", '1', time()+7200);
}

If you want to store TRUE in the cookie then you need to use a serialized array.
Code:
$value = array('logged_in' => TRUE);
$value = serialize($value);

$this->input->set_cookie("loggedin", $value, time()+7200);

$value = $this->input->cookie('loggedin', TRUE);
$value = unserialize($value);


Messages In This Thread
Why aren't my cookies writting? - by El Forum - 06-03-2012, 02:15 PM
Why aren't my cookies writting? - by El Forum - 06-03-2012, 05:35 PM
Why aren't my cookies writting? - by El Forum - 06-03-2012, 05:38 PM
Why aren't my cookies writting? - by El Forum - 06-03-2012, 05:42 PM
Why aren't my cookies writting? - by El Forum - 06-03-2012, 05:54 PM
Why aren't my cookies writting? - by El Forum - 06-03-2012, 05:56 PM
Why aren't my cookies writting? - by El Forum - 06-03-2012, 06:45 PM
Why aren't my cookies writting? - by El Forum - 06-03-2012, 06:59 PM
Why aren't my cookies writting? - by El Forum - 06-03-2012, 07:35 PM
Why aren't my cookies writting? - by El Forum - 06-03-2012, 07:58 PM
Why aren't my cookies writting? - by El Forum - 06-03-2012, 09:35 PM
Why aren't my cookies writting? - by El Forum - 06-04-2012, 04:51 AM
Why aren't my cookies writting? - by El Forum - 06-04-2012, 06:12 AM
Why aren't my cookies writting? - by El Forum - 06-04-2012, 07:52 AM
Why aren't my cookies writting? - by El Forum - 06-04-2012, 11:29 AM
Why aren't my cookies writting? - by El Forum - 06-04-2012, 11:34 AM
Why aren't my cookies writting? - by El Forum - 06-04-2012, 11:35 AM



Theme © iAndrew 2016 - Forum software by © MyBB