Added save-session-to-cookie functionality and related helper methods.