Glamorgan 462 for 4 (Carlson 170*, Cooke 133*) lead Northamptonshire 215 by 247 runs
Carlson's sublime 170 not out was the jewel in the crown of Glamorgan's 462 for 4 as he and captain Cooke (133 not out) shared an unbeaten club record fifth-wicket stand of 307.
Earlier in the day, Marnus Labuschagne (77) and Billy Root (45) also recorded a century partnership as Northamptonshire's bowlers toiled.
The Welsh side lead by 247 runs and will hope to bowl 10-man Northamptonshire out on the final day to seal what would be a shock victory.
Overnight batsman Labuschagne and Root had an untroubled first hour against a Northamptonshire seam attack without the injured Gareth Berg.
Australian star Labuschagne smashed 276 for Glamorgan's seconds last week and looked in effortless form again which was summed up by a superb drive through mid-on for four.
It forced the visitors to introduce spin option Simon Kerrigan into the attack. Labuschagne went to his 50 from 76 balls with eight fours thanks to a cut boundary from the bowling of Ben Sanderson.
Labuschagne's wonderful on-drive for four took his and Root's partnership past the three-figure mark with the latter more restrained but equally comfortable. Labuschagne looked completely untroubled and his shots grew increasingly aggressive so it was a surprise when he was clean bowled by Luke Procter for 77 when looking to leave.
Root followed him in the same fashion and in the same over when he chopped on for 45 attempting to play a cut shot when the ball was too close to his body.
Carlson and Cooke took Glamorgan past Northamptonshire's first-innings total of 215 and into the lead after lunch as they built on their top order's good work.
Carlson did edge Kerrigan for four between wicketkeeper and slip, but he and Cooke were otherwise untroubled even though there were two brief stoppages for rain. Carlson went to 50 from 81 balls with seven fours, but after the second break he was dropped by Rob Keogh off his own bowling as he delivered nine overs with Berg on the sidelines.
Soon, Carlson and Cooke's partnership was worth 100 with the latter bringing up his 50 from 87 balls. Glamorgan went to tea on 295 for 4 and in control.
Northamptonshire took the new ball for the third session, but Carlson remained unperturbed as he went to his third century of the season from 151 balls with a four off Procter through the leg side.
Cooke was dropped on 79 off the bowling of Sanderson by Kerrigan at point which summed up the visitors' day. It allowed the Glamorgan wicketkeeper to reach three figures from 186 balls with just four fours. His team also went well past 400 in the final session as both batsmen opened up with an overnight declaration possible.