store and retrieve cookie and calculate distance