Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
320 views
in Q2A Core by

I am checking the function qa_cookie_get_create() in qa-app-cookies.php, we have the following code there (v1.5.4):

    function qa_cookie_get_create()
    {
        if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); }
        
        require_once QA_INCLUDE_DIR.'qa-db-cookies.php';

        $cookieid=qa_cookie_get();
        
        if (isset($cookieid) && qa_db_cookie_exists($cookieid))
            ; // cookie is valid
        else
            $cookieid=qa_db_cookie_create(qa_remote_ip_address());
        
        setcookie('qa_id', $cookieid, time()+86400*365, '/', QA_COOKIE_DOMAIN);
        $_COOKIE['qa_id']=$cookieid;
        
        return $cookieid;
    }

 

As far as I can see, in case that $cookieid is set already, it goes to line setcookie() to set the cookie again?!

Shouldn't it be that it returns the $cookieid immediately - without setting it anew!
Like that:

        if (isset($cookieid) && qa_db_cookie_exists($cookieid))
            return $cookieid; // cookie is valid
 

Kai

Q2A version: 1.5.3

Please log in or register to answer this question.

...