In this paper we use cohomology of Lie algebras to study the variety of laws associated with filiform Lie algebras of a given dimension. As the main result, we describe a constructive way to find a small set of polynomials which define this variety. It allows to improve previous results related with the cardinal of this set. We have also computed explicitly these polynomials in the case of dimensions 11 and 12.