Preheat the oven to gas 5, 190°C, fan 170°C. Butter a 1.5-1.8 litre (2½-3 pint) ovenproof dish.
Tip the spinach into a large heatproof bowl, pour over boiling water, then leave for a few seconds to wilt. Tip into a colander, then run under cold water. Drain and squeeze to remove any excess liquid. Dry with kitchen towel and set aside.
To make the cheese sauce, combine both the cheeses in a bowl. Melt half the butter in a pan. Stir the flour into the butter and cook for a minute. Remove from the heat and gradually stir in the milk. Return to the heat and bring to the boil, stirring constantly. Simmer for 1-2 minutes, then remove from the heat and stir in the cream, chives and 2/3 of the cheese and season.
Layer a third of the potato slices in a casserole dish in overlapping slices, then top with a third of the shallots. Season. Scatter over half the spinach, a pinch of nutmeg, then half the ham. Pour over half the cheese sauce. Continue the layering with another third of the potatoes and shallots and some seasoning. Follow with the rest of the spinach, nutmeg, ham and sauce. Finish with a layer of potato and shallot and some seasoning. Dot with the rest of the butter, then scatter over the remaining cheese.
Put the dish on a baking sheet. Bake for about 1¼ hours, until the dish is bubbling and golden on top and the potatoes are tender. Cover loosely with foil for the last 25-30 minutes if the top is getting too brown. Remove and leave to settle for 5 minutes, then serve scattered with some extra chives.
For top tips on protecting you and your family when preparing raw meat and poultry, visit Food Safety in the Home.