Implement cookies encrypt/decrypt

Also contains bugfixes