Extract cookie getting and setting to methods