Support for custom cookie store

Related to #1187

This makes it possible to exchange cookie store.