Move session header creation into its own function