Secondary Cohomology and $k$-invariants