Heat the butter in a soup pot over moderate heat. Add the onions and cook, stirring frequently, until caramelized, about 40 minutes.
Add the garlic and cook, stirring, until fragrant, about 1 minute. Remove the pot from the heat and add the brandy. Return the pot to the heat and cook, stirring occasionally, until almost dry. Sprinkle the onions with the flour and cook, stirring, for 3 minutes. While stirring, slowly add the broth. Bring the soup to a boil, lower the heat, and simmer, with the cover slightly ajar, about 20 minutes. Season the soup with salt and pepper.
Arrange a rack about 4 inches from the broiler and preheat.
Arrange 6 ovenproof crocks or deep soup bowls on a baking sheet and ladle the hot soup into them. Arrange 2 slices of toasted bread on top of each soup and sprinkle with the cheese.
Broil the soups until the cheese is melted and bubbling. Serve immediately.