fix typo in type checking, add helpers in controller
serialize cookie