verify and generate functions for checking cookie