Step 1: Note the symmetric limits.
We must find $I=\int_{-\pi}^{\pi}\dfrac{\cos^2x}{1+a^x}\,dx$. The limits are symmetric about zero, so a special property will help.
Step 2: Use the king property.
The rule $\int_{-c}^{c}f(x)\,dx=\int_{-c}^{c}f(-x)\,dx$ lets us replace $x$ by $-x$. Doing so, $\cos^2x$ stays the same and $a^x$ becomes $a^{-x}$: \[ I=\int_{-\pi}^{\pi}\frac{\cos^2x}{1+a^{-x}}\,dx. \]
Step 3: Tidy the second form.
Since $\dfrac{1}{1+a^{-x}}=\dfrac{a^x}{1+a^x}$, the second integral is \[ I=\int_{-\pi}^{\pi}\frac{a^x\cos^2x}{1+a^x}\,dx. \]
Step 4: Add the two forms.
Adding the original $I$ and this new $I$: \[ 2I=\int_{-\pi}^{\pi}\cos^2x\cdot\frac{1+a^x}{1+a^x}\,dx=\int_{-\pi}^{\pi}\cos^2x\,dx. \]
Step 5: Evaluate the clean integral.
Since $\cos^2x$ is even, $\int_{-\pi}^{\pi}\cos^2x\,dx=2\int_0^{\pi}\cos^2x\,dx$. Using $\cos^2x=\tfrac{1+\cos2x}{2}$, $\int_0^{\pi}\cos^2x\,dx=\tfrac{\pi}{2}$. So $2I=2\cdot\tfrac{\pi}{2}=\pi$.
Step 6: Solve for $I$.
Dividing by $2$, \[ I=\frac{\pi}{2}. \]
\[ \boxed{\dfrac{\pi}{2}} \]