flags and cookie handling