add optional and required parameter, add cookie support