move save/load cookie functions up