improve validator
fixed #5 and support cookie style