The key to making things stay cold for a long time in a cooler is:
Get a cooler appropriate for the job--the same principles apply to any cooler, but a well made/well insulated one like a Yeti will keep things cooler longer than a cheap one
Do not open the cooler any more than absolutely necessary! Each time you open it, the temperature inside will try to equilibrate with the temperature outside
Pack it full to leave as little air space as possible. Solids and liquids are slower to heat up than gas. This is why you shouldn't empty the water in a cooler with melting ice. As long as ice remains, the water will remain at just above freezing temp.
If you don't need to open it at all for a long time, tape around the lid seam with duct tape