[1.6.x] Fixed #21448 -- Fixed test client logout with cookie-based sessions

Thanks Gunnar Scherf for the report and the suggested patch.
Backport of 384816fcc from master.