Why a cold glass of beer goes flat?

Carbonation of beer is a direct result of the temperature of the beer and the pressure of CO2 it is held under above normal atmospheric pressure of 1 atmosphere (a bastardisation of Boyles law if you want the theory). In the case of a glass of beer, no matter how cold it is kept, it is open to the atmosphere which is no differential pressure and very little CO2. The CO2 in the beer therefore wants to equalise with the atmosphere and hence escapes making the beer flat.

Solution? drink the beer.