If you cook food and you aren't going to eat all of it immediately, cool it as quickly as possible and then refrigerate or freeze it. You shouldn't leave out cooked foods at room temperature, because this could allow bacteria to grow and multiply.
If you keep cooked food in the fridge, eat it within two days. If you freeze it, it should be safe to keep it for a long time, providing it remains frozen. However, keeping food frozen for too long can affect its taste and texture, so it's a good idea to follow the freezer manufacturer's instructions about how long to store certain foods.