function qa_cookie_get_create() { require_once QA_INCLUDE_DIR . 'qa-db-cookies.php'; $cookieid = qa_cookie_get(); if (isset($cookieid) && qa_db_cookie_exists($cookieid)) { } else { $cookieid = qa_db_cookie_create(qa_remote_ip_address()); } setcookie('qa_id', $cookieid, time() + 86400 * 365, '/', QA_COOKIE_DOMAIN); return $cookieid; }
function qa_db_cookie_create($ipaddress) { for ($attempt = 0; $attempt < 10; $attempt++) { $cookieid = qa_db_random_bigint(); if (qa_db_cookie_exists($cookieid)) { continue; } qa_db_query_sub('INSERT INTO ^cookies (cookieid, created, createip) ' . 'VALUES (#, NOW(), COALESCE(INET_ATON($), 0))', $cookieid, $ipaddress); return $cookieid; } return null; }
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)) { } 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; }