protected function setCookie($value, array $params)
    {
        if (headers_sent()) {
            throw new TokenStorageException('Cannot store CSRF token, headers already sent');
        }

        return setcookie(
            $params['name'],
            $value,
            $params['expire'],
            $params['path'],
            $params['domain'],
            $params['secure'],
            $params['httpOnly']
        );
    }