span style="color: #0000BB"><?php//DB//$db = DB::singleton();//COOKIES//$user = array();if (@$_COOKIE[INI_COOKIE_NAME]) { // INDEX KEY `cookie_id` $qt = 'SELECT * ' . 'FROM `users` ' . 'WHERE `users`.`cookie_id` = ? ' . 'LIMIT 1;'; $args = array($_COOKIE[INI_COOKIE_NAME]); $q = $db->prepare($qt); // Fixed if ($q and $q->execute($args) and $q->rowCount()) { $user = $q->fetch(); if ($user['cookie_timestamp'] < $_SERVER['REQUEST_TIME']) { $_COOKIE[INI_COOKIE_NAME] = md5(uniqid()); $qt = 'UPDATE `users` ' . 'SET `users`.`cookie_timestamp` = ?, ' . '`users`.`cookie_id` = ? ' . 'WHERE `users`.`user_id` = ? ' . 'LIMIT 1;'; $args = array($_SERVER['REQUEST_TIME'] + INI_COOKIE_LIFETIME, $_COOKIE[INI_COOKIE_NAME], $user['user_id']); if ($db->prepare($qt)->execute($args)) { setcookie(INI_COOKIE_NAME, $_COOKIE[INI_COOKIE_NAME], INI_COOKIE_EXPIRE, INI_COOKIE_PATH, INI_COOKIE_DOMAIN, INI_COOKIE_SECURE, INI_COOKIE_HTTPONLY); } } } else { setcookie(INI_COOKIE_NAME, null, 0, INI_COOKIE_PATH, INI_COOKIE_DOMAIN, INI_COOKIE_SECURE, INI_COOKIE_HTTPONLY); unset($_COOKIE[INI_COOKIE_NAME]); }} |