We propose optimization strategies for cooperating households equipped with renewable energy assets and storage devices. We consider two system configurations: In the first configuration, households share access to an energy farm, where electricity is generated from renewable sources and stored in battery banks. In the second configuration, households are equipped with their own renewable energy sources and storage devices, and are allowed to share energy through the grid. The developed optimization model takes into account location and time-varying energy prices as well as energy transfer fees. To design our strategies, we first establish performance bounds, and compare the two configurations in terms of achievable savings and usability of renewable energy. Then, we devise real-time energy management algorithms by incorporating forecasting techniques in the proposed framework. Simulation results show that the proposed strategies outperform existing solutions by up to 10%. It is also shown that cooperative strategies outperform greedy approaches by up to 6.8%.