Try to convert hostname to production hostname before checking if current hostname is primary domain for a realm. Should fix cookie not being session cookie on snapshot and test.