My page sets signin_time sets it to NOW(), sets logged_in to 1 when user successfully signs into page. What I want to do is to set signout_time to NOW() when user signs out too. For this purpose I'm using following query
$stmt = $db->prepare("UPDATE `ulog` SET `logged_in`=0, `signout_time`=NOW(),`ckey`= '', `ctime`= '' WHERE user_id=? AND logged_in=1") or die($db->error);
I tried to execute this query. It didn't return any error message, but I haven't noticed any change in db table too, also php error log doesn't show anything.
Maybe I have syntax error (I'm setting logged_in=0 where logged_in=1). I have no other idea how to do that. Maybe I should search for rows where signout_time=0?  Any suggestions? 
Update
Here is whole function:
function logout() {
    global $db, $wsurl;
    if (isset($_SESSION['user_id'])) {
        $userid = $_SESSION['user_id'];
        $stmt = $db->prepare("UPDATE `ulog` SET `logged_in`=0, `signout_time`=NOW() WHERE user_id=? AND logged_in=1") or die($db->error);
    } else {
        $userid = $_COOKIE['user_id'];
        $stmt = $db->prepare("UPDATE `ulog` SET `logged_in`=0, `signout_time`=NOW(),`ckey`= '', `ctime`= '' WHERE user_id=? AND logged_in=1") or die($db->error);
    }
    $stmt->bind_param("i", $userid) or die($stmt->error);
    $stmt->execute() or die($stmt->error);
    $stmt->close();
    $_SESSION = array(); //destroy all of the session variables}
    session_destroy();
    foreach ($_COOKIE as $c_id => $c_value) {
        setcookie($c_id, '', 1, "/");
    }
    header("Location: " . $wsurl);
}
 
     
     
    