Moved cookie retrieval code to util class