Melt 1 tablespoon of butter in a pan over medium heat. Add the onions and saute for 2-3 minutes until transparent and slightly browned on the edges.
Cook the onions without stirring for 2-3 minutes, until the onions brown to the bottom of the pan. Deglaze with a splash of water, and stir, scraping up the browned bits. Repeat for about 8 minutes, until the onions are a deep caramelized brown colour.
Remove the onions from the pan, and continue to heat the pan over medium-low heat.
With the remaining butter, butter the slices of bread. Place two pieces, buttered sides down, on a cutting board and divide the onions between them. Add the shredded cheese. Top with the last two slices of bread, buttered sides facing up.
Transfer one of the sandwiches to the hot pan, frying for 2-3 minutes per side, until crispy and golden, and the cheese is melty inside. Repeat with the second sandwich.