  We determine the complex-valued solutions of the following functional
equation \[f(xy)+\mu (y)f(\sigma (y)x) = 2f(x)g(y),\quad x,y\in S,\] where $S$
is a semigroup and $\sigma$ an automorphism, $\mu :S\rightarrow \mathbb{C}$ is
a multiplicative function such that $\mu (x\sigma (x))=1$ for all $x\in S$.
