If $(f\circ g)(x)=x$ does $(g\circ f)(x)=x$? Given  $$(f◦g)(x)=x$$ (from R to R for any x in R)  
does it mean that also $$(g◦f)(x)=x$$
I feel like its not true but I can't find counter example :(
I tried numerous ways for several hours but I cant counter it though I almost know for sure that this will only be true if g is onto but I don't know why :P

Take, for example, $f(x) = \ln(x)$ and $g(x) = e^x$.
Then, for every $x\in\mathbb R$, you have $f(g(x))=\ln(e^x) = x$. But that is not true the other way around, i.e. the statement:

For every $x\in \mathbb R: g(f(x)) = x$

is a false statement, because $f(x)$ is not defined for $x\leq0$.

If you want $f$ to be defined everywhere, you can define
$$f(x)=\begin{cases}\ln|x| & \text{if } x\neq 0\\
0&\text{if } x = 0\end{cases}.$$
You then have, for every $x\in\mathbb R$: $f(g(x)) = f(e^x)$ which, because $e^x\neq 0$, is equal to $\ln(|e^x|) = \ln(e^x)=x$.
On the other hand, you have, for every $0\neq x\in \mathbb R$,$g(f(x)) = e^{\ln|x|} = |x|$, so if $x<0$, $g(f(x))$ is not equal to $x$.
