codeigniter cookie expiry problem

后端 未结 3 1651
别跟我提以往
别跟我提以往 2021-01-19 07:19

I\'m having a cookie issue, the expiry date on my cookie is always being set to At End Of Session which isn\'t what I want. I did a bit of goggling and it suggested it set t

3条回答
  •  终归单人心
    2021-01-19 07:52

    Your expiry date is set incorrectly. You don't have to include the time(), as what you're setting is actually the expiry date from time().

    When you have an incorrect expire value, it defaults to 0, which is set as your session's length instead.

    Therefore it should be:

                $cookie = array(
                'name'   => 'basket_id',
                'value'  => $basket_id,
                'expire' => 86400*30,
                'domain' => 'domain',
                'path'   => '/',
                'prefix' => '',
            );
    

提交回复
热议问题