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

[eluser]dkindler[/eluser]
Would anyone happen to know why my program fails to write my cookies?

Code:
function login() {
  $this->input->set_cookie("loggedin", TRUE, 7200) or die ("failure to write cookie");
}

and


Code:
function check_global_password($global_password) {
  $pw_in_question = $this->encrypt->decode($global_password);
  $query = $this->db->get('confidentials');
  foreach ($query->result() as $pw) {
   $pw = $pw->password;
  }

  if ($pw == $pw_in_question) {
   $this->session_model->login();
  } else {
   redirect($_SERVER['HTTP_REFERER']);
  }
}


Thank you
#2

[eluser]rthut[/eluser]
It just dies at the "die" statment ?
How many results are returned from the table 'confidentials' ?
#3

[eluser]dkindler[/eluser]
No, if the cookie doesn't write it executes the die statement. Im using that to debug.

Only a single result is returned. Everything is working correctly, It's just not writting the cookie.
#4

[eluser]rthut[/eluser]
Try to pass an array like this:

Code:
$cookie = array(
    'name'   => 'The Cookie Name',
    'value'  => 'The Value',
    'expire' => '86500',
    'domain' => '.some-domain.com',
    'path'   => '/',
    'prefix' => 'myprefix_',
    'secure' => TRUE
);

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

[eluser]Learn CodeIgniter[/eluser]
Code:
secure => TRUE // is for https:// not http://
#6

[eluser]rthut[/eluser]
[quote author="Learn CodeIgniter" date="1338771260"]
Code:
secure => TRUE // is for https:// not http://
[/quote]

Just copy/paste from the doc's: http://ellislab.com/codeigniter/user-gui...input.html
#7

[eluser]dkindler[/eluser]
[quote author="rthut" date="1338771365"][quote author="Learn CodeIgniter" date="1338771260"]
Code:
secure => TRUE // is for https:// not http://
[/quote]

Just copy/paste from the doc's: http://ellislab.com/codeigniter/user-gui...input.html[/quote]


Nope, still getting a faliure to write cookie... Here is my code now:

Code:
function login() {
  $cookie = array(
      'name'   => 'login',
      'value'  => 'hi',
      'expire' => '7200',
      'domain' => '',
      'path'   => '',
      'prefix' => '',
      'secure' => TRUE
  );
  
  $this->input->set_cookie($cookie) or die ("failure to write cookie");
}
#8

[eluser]rthut[/eluser]
Is your app under an https connection ? if not, try to set secure => false
#9

[eluser]Learn CodeIgniter[/eluser]
As I stated above the secure is only for a https:// connection
Quote:secure php.net
Indicates that the cookie should only be transmitted over a secure HTTPS connection from the client. When set to TRUE, the cookie will only be set if a secure connection exists. On the server-side, it's on the programmer to send this kind of cookie only on secure connection (e.g. with respect to $_SERVER["HTTPS"]).

It should be set to FALSE.

You can also use the Codeigniter cookie_helper
#10

[eluser]dkindler[/eluser]
still failing :/




Theme © iAndrew 2016 - Forum software by © MyBB