Boiled eggs last up to 7 days in the refrigerator whether they are peeled or unpeeled, as long as they are stored properly. Unpeeled eggs should be kept in a sealed container to prevent odor absorption, while peeled eggs should be stored in an airtight container, ideally with a damp paper towel to maintain moisture. It is important to refrigerate boiled eggs within two hours of cooking and not leave them at room temperature for more than two hours to avoid bacterial growth.