To test that, I tried looking for that phrase in French, and found it… attributed to George Bernard Shaw:
Celui qui n’est pas communiste à vingt ans n’a pas de coeur; celui qui l’est encore à quarante ans n’a pas de tête.
(Whoever is not a communist at twenty does not have a heart; whoever is still one at forty does not have a head.)