Solution 1:

Your professor seems not to emphasize sufficiently the contrast between the cotangent space to an affine variety and the cotangent space to a general variety.
I'll examine the classical case of varieties over an algebraically closed field (the generalization to schemes is not so difficult but attention must then be given to the distinction between point, closed point and rational point).

A) For a general variety $V$ and a point $p\in V$, we consider the local ring $\mathcal O_{V,p}$ and its maximal ideal $\mathfrak m_p\subset \mathcal O_{V,p}$.
The cotangent $k$-vector space is $T^*_p(V)=\frac {\frak m_p}{\frak m_p^2}$.
Given the germ $\phi=\tilde f\in \mathcal O_{V,p}$ of a regular function $f\in\mathcal O(U)$ defined in an open neighbourhood $U$ of $p$, the differential of $f$ or $\phi$ at $p$ is $$d_pf=d_p\phi=[f-f(p)]\in \frac {\frak m_p}{\frak m_p^2} $$ Note carefully that it is absolutely impossible to define $T^*_p(V)$ in terms of the global regular functions $\mathcal O(V)$ or in terms of the global tangent vector fields $\mathcal X(V)=\Gamma(V,T(V))$.

B) However in the case of an affine variety $V$ with algebra of global functions $A:=\mathcal O(V)$ we can use the global regular functions $A$ to define the cotangent vectorspace at $p$ of $V$. Here is how:
Define $M_p\subset A$ to be the ideal of global functions $g\in A$ such that $g(p)=0$.
We have a canonical morphism restriction map $r:\frac {M_p}{M_p^2}\to \frac {\frak m_p}{\frak m_p^2}$ and this morphism is bijective.
Hence the transposed morphism $r^*:(\frac {\frak m_p}{\frak m_p^2})^*\to (\frac {M_p}{M_p^2})^*$ is also an isomorphism (of $k$-vector spaces) and this allows us to define, if one so wishes, $T^*_p(V)=\frac {M_p}{M_p^2}$.

C) Everything above remains correct if one replaces affine varieties by differential manifolds.
Hence in the excellent manifold theory books by Tu and Lee they define the cotangent space to the manifold $M$ by using the $\mathbb R$-algebra of global differentiable functions $C^\infty(M)$, in the spirit of the procedure described in B).
There should be more publicity about the close similarity between differential manifolds and affine algebraic varieties (and the vast gap between differential manifolds and projective algebraic varieties).