Preheat the oven to 350°F. Cut the loaves of bread in half lengthwise as if you’re going to make a sandwich.
Combine the 1 cup mayo and 2 cups shredded cheddar cheese in a bowl and spread on both side of both loaves of bread.
Place thinly sliced onion and ham in each sandwich to your liking.
Wrap sandwiches in aluminum foil and and bake until cheese is melted and the sandwiches are heated throughout.