Cerri headed in the winner in the sixth minute of injury time to spark wild celebrations among the home team and fans as Cagliari moved back into fourth spot in the Italian standings.
Cerri had replaced Giovanni Simeone only three minutes earlier.
Sampdoria led 2-0 then 3-1 in the 70th minute before a double from João Pedro pulled Cagliari level.
Radja Nainggolan scored Cagliari’s first goal.
Last season’s top goalscorer in Serie A, Fabio Quagliarella, netted two of Sampdoria’s goals — one a penalty — and Gastón Ramírez scored the visitors’ second.
Source: Fox Sports