If I enter the important integral
Integrate[(2/Pi)*Cos[l x] Cos[m x], {x, 0, Pi}]FullSimplify[%, Element[l, Integers] && Element[m, Integers]]
I get the responses:$$\frac{2l\cos m\pi \sin n\pi-2m\cos l\pi \sin m\pi}{(l^2-m^2)\pi}$$$$0$$
Clearly this doesn't take into consideration that $l$ may equal $m$. How can I enter an integral with similar assumptions and not allow Mathematica to make a similar mistake? For example, I entered
FullSimplify[Integrate[(2/Pi) Sin[x]^2*Cos[l x], {x, 0, Pi}], Element[l, Integers]]
and it gives me the solution $0$, without considering that $l$ may equal $2$, for which this solution is not valid. I am lucky my professor caught the mistake, but I am looking a method to do it so it gives me the Kronecker delta, if possible. Thanks.
Edit: My example was copied incorrectly; what I am looking for is a ubiquitous method that doesn't rely on me already knowing that there may be a Kronecker delta.