Let $$(S,\cdot )$$ (S,·) be a semigroup, $$\mathbb {C}$$ C be the set of complex numbers, and let $$\sigma ,\tau \in Hom(S,S)$$ σ,τ∈Hom(S,S) satisfy $$\tau \circ \tau =\sigma \circ \sigma =id.$$ τ∘τ=σ∘σ=id. We show that any solution $$f:S \rightarrow \mathbb {C}$$ f:S→C of the functional equation $$\begin{aligned} f(x\sigma (y))+\chi (y)f(\tau (y)x)=2f(x)f(y), \quad x,y \in S, \end{aligned}$$ f(xσ(y))+χ(y)f(τ(y)x)=2f(x)f(y),x,y∈S, has the form $$f=(m+\chi \, m\circ \sigma \circ \tau )/2$$ f=(m+χm∘σ∘τ)/2 , where m is a multiplicative function on S and $$\chi :S\rightarrow (\mathbb {C}\backslash \{0\},\cdot )$$ χ:S→(C\{0},·) is a character on S (i.e., $$\chi (xy)=\chi (x)\chi (y)$$ χ(xy)=χ(x)χ(y) for all $$x,y\in S$$ x,y∈S ) which satisfies $$\chi (x\tau (x))=1$$ χ(xτ(x))=1 for all $$x\in S$$ x∈S .