Move cookies handling to a core module

Resolves #293