Welcome Guest, Not a member yet? Register   Sign In
Is CI setting new cookies to expire yesterday?
#1

I'm having problems setting a cookie:

PHP Code:
$this->input->set_cookie('XDEBUG_PROFILE'$set); 

The cookie immediately expires the moment it is created. I've chased the problem down to this:

In 3.1.7, in the /system/core/input.php file at line 399, we find this code for setting the expiration of a cookie:

PHP Code:
        if ( ! is_numeric($expire))
        {
            $expire time() - 86500;
        }
        else
        
{
            $expire = ($expire 0) ? time() + $expire 0;
        

If you don't explicitly pass an expiration time, it defaults to 24 hours ago. Which means cookies will immediately disappear.

Is this a bug? Shouldn't the default expiration time be zero so the cookie expires when the session is ended?

It's not ideal or obvious, but for a work around, we can add an explicit zero for the expiration time like this:

PHP Code:
$this->input->set_cookie('XDEBUG_PROFILE'$set0); 

Should I submit a bug report for this or am I missing something?
Reply


Messages In This Thread
Is CI setting new cookies to expire yesterday? - by pbarney - 01-25-2018, 11:36 AM



Theme © iAndrew 2016 - Forum software by © MyBB