private function verifySocket($ip)
    {
        if ($ip) {
            $_SERVER['REMOTE_ADDR'] = $ip;
        }

        preg_match ('#PHPSESSID=([^;\s]+)#', $_SERVER['HTTP_COOKIE'] ?? false, $array, PREG_OFFSET_CAPTURE);

        $session_id = $array[1][0] ?? false;

        if (!$session_id) {
            print 'Failed to capture PHPSESSID' . PHP_EOL;
            die(1);
        }

        $db = Database::database();
        $sql = 'SELECT count(*) FROM sessions WHERE user_ip = ? AND session_id = ? LIMIT 1';
        $stmt = $db->prepare($sql);
        $stmt->execute([$_SERVER['REMOTE_ADDR'], $session_id]);
        $session = $stmt->fetchColumn();
        self::$session_id = $session_id;
        if (!$session) {
            if (SOCKET) {
                print 'BAD ADDRESS :: ' . $_SERVER['REMOTE_ADDR'] . "\n\n";
            }
            die(0);
        }
        session_id($session_id);
    }