To maximize the shelf life of cooked onions for safety and quality, refrigerate the onions in shallow airtight containers or resealable plastic bags. ... Bacteria grow rapidly at temperatures between 40 °F and 140 °F; cooked onions should be discarded if left out for more than 2 hours at room temperature.