浏览器在codeigniter中关闭时,cookie会消失

时间:2013-09-04 17:38:16

标签: php cookies setcookie

当我关闭浏览器时,Cookie消失了。当我再次打开浏览器时,我看不到它。我的代码是

    $this->sesdata = array(
                    'shop_user'  => $username,
                    'shop_password'  => $password,
                    'logged_in' => TRUE
                              );

    $this->CI->session->set_userdata($this->sesdata);


    $this->cookie = array(
        'name'   => 'user',
        'value'  => $username,
        'expire' => time()+86500,
        'domain' => '',
        'path'   => '/',
        'prefix' => '',
    );

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

    $this->cookie1 = array(
        'name'   => 'pass',
        'value'  => $password,
        'expire' => time()+86500,
        'domain' => '',
        'path'   => '/',
        'prefix' => '',
    );

    $this->CI->input->set_cookie($this->cookie1);

1 个答案:

答案 0 :(得分:0)

expire的值应仅为数字。不要添加当前时间,因为传递的值是从现在开始应该保持的秒数。有关详细信息,请参阅documentation