Improve cookies. Smart function for choosing the right domain