Cohomology of wedge equals direct sum of cohomologies

I have seen the following fact used somewhere (for example to show that $\mathbb{RP}^3$ is not homotopy equivalent to $S^3\vee\mathbb{RP}^2$):

Let $X,Y$ be two path connected pointed spaces such that the base points each have a contractible neighborhood. Then: $$H^\bullet(X\vee Y)\cong H^\bullet(X)\oplus H^\bullet(Y)$$

I have two questions:

  1. In what category do we have to take the direct sum? Intuitively, I would say the category of $R$-algebras. Is it correct, or should we do it in the category of rings, or something else?
  2. How can I show this? It is pretty easy to show something similar, namely that the reduced cohomology of the wedge of such spaces is isomorphic to the product of the reduced cohomologies as $R$-modules (and this is true for arbitrary wedges, not only finite ones). However, i don't know how to proceed for the statement above. Should I try to show that the universal property holds?

As a statement about unreduced cohomology, this is incorrect (for $\bullet = 0$). The correct statement for unreduced cohomology is that

$$H^{\bullet}(X \sqcup Y) \cong H^{\bullet}(X) \times H^{\bullet}(Y)$$

where $\sqcup$ denotes the disjoint union, not the wedge sum. I write the product $\times$ on the RHS instead of the direct sum because

  1. While the two have the same underlying abelian group, the correct universal property of the RHS as a ring is that it is the product, and
  2. For an infinite disjoint union the answer continues to be the infinite product rather than the infinite direct sum (which lacks a multiplicative identity).

As a statement about reduced cohomology, this is fine on the level of abelian groups (and it can be proven using Mayer-Vietoris), but when taking into account the cup product you run into the annoying issue that reduced cohomology doesn't have a multiplicative identity.

One fix is to regard the cohomology of a pointed topological space $(X, \text{pt})$ as a pair consisting of a ring $H^{\bullet}(X)$ and an augmentation $H^{\bullet}(X) \to H^{\bullet}(\text{pt})$ (so reduced cohomology is the kernel of this map, also known as the augmentation ideal), and then the statement is that cohomology takes the pushout $X \vee Y$ to the corresponding pullback of the diagram $H^{\bullet}(X) \to H^{\bullet}(\text{pt}) \leftarrow H^{\bullet}(Y)$ (as an augmented ring, so keeping the induced map to $H^{\bullet}(\text{pt})$).