From Boyd & Vandenberghe's Convex Optimization:
$\textsf{Example 2.7}\;\;$ The positive semidefinite cone $\mathbf{S}_+^n$ can be expressed as
$$ \bigcap_{z\not=0} \{ X \in \mathbf{S}^n \mid z^TXz \geq 0 \}. $$
For each $z \not= 0$, $z^TXz$ is a (not identically zero) linear function of $X$, so the sets
$$ \{ X \in \mathbf{S}^n \mid z^TXz \geq 0 \} $$
are, in fact, halfspaces in $\mathbf{S}^n$. Thus the positive semidefinite cone is the intersection of an infinite number of halfspaces, and so is convex.
Why is $z^T X z$ a linear function in matrix $X$? I don't understand what to do when the variable is a matrix.
Because your matrix $X$ is like a container of variables, and you can write :
$$z^\top X z = \sum_{i=1}^N \sum_{j=1}^N z_i z_j X_{ij}$$
As you can see, the function $f(X)$ is linear in the variables $X_{ij}$ which are contained in $X$.