Refactor cookie to prepare for external callbacks

Also adds flexibility to the verification process.
2 files changed