On as a second-half substitute, Cooke tapped in his first goal of the season much the relief of the City fans who had seen their side struggle to break down a determined Gillingham side.
In fact neither side had created a noteworthy chance in the entire match until Dean Windass beat goalkeeper Tony Bullock to a though ball with just two minutes left on the clock.
Windass kept his composure as he rounded Bullock but found the angle too tight to take the shot on himself. Instead he slid the ball across the face of the goal were he found Cooke who could not miss from a yard out.
It was harsh on Gillingham who must have thought that had done enough to earn a point with a stubborn display.
Chances were at a real premium for both sides in what was a largely drab affair.
Veteran striker Steve Claridge missed the game's opening chance after just two minutes.
Bobby Petta's through ball presented the 39-year-old hitman with the shooting chance but he curled his shot too close to Bullock who pushed the ball away from danger with relative ease.
City midfielder Steve Schumacher blazed over after 11 minutes and then home skipper David Wetherall wasted a decent chance 10 minutes before the break. Petta's corner was flicked on at the near post but Wetherall headed wide of the post.
The travelling Gillingham fans had to wait until just before half time before their side threatened to break the deadlock when Matthew Jarvis beat the on rushing Donovan Ricketts to a through ball.
Jarvis squeezed the ball under the legs on the Jamaican international goalkeeper but teenage full-back Andrew Taylor was on the line to mop up the danger.
The second half followed in much the same manner as the first with neither side creating anything in the opposition's box.
With 18 minutes left Todd replaced Claridge with Cooke, but the game looked as though it would end in stalemate until Cooke's tap in papered over the obvious cracks this City side seem to have when playing in front of their own fans.