As long as both flights are international flights, you can stay "airside" and not clear customs. There should be a transit desk to confirm your onward flight.
you can it from your Amphur office where your marriage is registered, it shows your marriage is still valid, it cost about 30thb or mine has been free last two visits.
you have to be "airside" (booked in and through customs) this can only be done 2 or 3 hours before your flight, if your in the terminal public areas you are still counted as being in Thailand.