Welcome Guest, Not a member yet? Register   Sign In
return cookie value
#1

[eluser]ibnclaudius[/eluser]
I'm setting the cookie like this:
Code:
$cookie = array(
         'name'   => $this->remember['name'],
         'value'  => $token,
         'expire' => '86500',
         'domain' => '',
         'path'   => '/',
         'prefix' => '',
         'secure' => TRUE
       );

     setcookie($cookie);

And returning it's value like this, but it output nothing:
Code:
get_cookie($this->remember['name'])

What is wrong?
#2

[eluser]Denzel[/eluser]
Please provide us with a little bit more information. First, what exactly do you mean by "output nothing." That appears to be the expected behavior from a fleeting glance at your code; there are no statements made that output anything.

I don't know what you intended, maybe it was just a typo, but you are calling setcookie, PHP's built-in function, not set_cookie, CodeIgniter's alias for Input:Confusedet_cookie. Maybe that's what you wanted, but we can't tell from what you have provided here.

Provide some more context so we can help you better.
#3

[eluser]ibnclaudius[/eluser]
Running:
Code:
echo get_cookie($this->remember['name'])
Don't output anything...

I want to set a cookie and check if it exists and returns it value...
#4

[eluser]ibnclaudius[/eluser]
I'm doing this, if the user login with the remember me checked, create a cookie and insert it in database, the database part is ok, but I don't if the cookie is being set. Confused
Code:
public function login($email, $password, $remember)
{
  $email = trim($email);
  $password = sha1(trim($password));
  
  $user = $this->CI->auth_mod->login($email, $password);
  
  if ($user)
  {
   if ($this->roles['active'] === TRUE && $user['active'] === FALSE)
   {
    echo $this->errors['not_active'];
   }
   else
   {
    $session = array(
      'logged' => TRUE,
      'id' => $user['id'],
      'name' => $user['name'],
      'email' => $user['email'],
      'active' => $user['active']
    );
    
    $this->create_user_session($session);
    
    if ($this->remember['active'] === TRUE && $remember === $this->remember['name'])
    {
     $token = sha1(uniqid(rand(), TRUE));
    
     $this->CI->auth_mod->create_user_session($user['id'], $token);
    
     $cookie = array(
         'name'   => $this->remember['name'],
         'value'  => $token,
         'expire' => '86500',
         'domain' => '',
         'path'   => '/',
         'prefix' => '',
         'secure' => TRUE
       );

     $this->CI->input->set_cookie($cookie);
    }
    
    redirect($this->redirects['logged'], 'location');
   }
  }
  else
  {
   echo $this->errors['invalid_login'];
  }
}

So, when the user logout, delete his session and if there's a cookie, delete it and from the database, but again, everything works, except the cookie part, it's not deleted, also from the database... I don't know if the cookie is being set..
Code:
public function logout()
{
  $this->CI->session->sess_destroy();
  
  $session_token = $this->CI->input->cookie($this->remember['name']);
  
  if ($session_token)
  {
   $this->auth_mod->delete_user_session($session_token);
  }
  
  redirect($this->redirects['logged_out'], 'location');
}

Sorry for the english Confused
#5

[eluser]InsiteFX[/eluser]
This should be FALSE!
Code:
'secure' => FALSE

Only set to true if your running the server in SSL secure!




Theme © iAndrew 2016 - Forum software by © MyBB