support cookie
support cookie and fix bug in on_exit hook