Refactor cookie setting logic and use selenium add cookies method