The emergence of cooperation among unrelated human subjects is a long-standing conundrum that has been amply studied both theoretically and experimentally. Within the question, a less explored issue relates to the gender dependence of cooperation, which can be traced back to Darwin, who stated that "women are less selfish but men are more competitive". Indeed, gender has been shown to be relevant in several game theoretical paradigms of social cooperativeness, including prisoner's dilemma, snowdrift and ultimatum/dictator games, but there is no consensus as to which gender is more cooperative. We here contribute to this literature by analyzing the role of gender in a repeated Prisoners' Dilemma played by Spanish high-school students in both a square lattice and a heterogeneous network. While the experiment was conducted to shed light on the influence of networks on the emergence of cooperation, we benefit from the availability of a large dataset of more 1200 participants. We applied different standard econometric techniques to this dataset, including Ordinary Least Squares and Linear Probability models including random effects. All our analyses indicate that being male is negatively associated with the level of cooperation, this association being statistically significant at standard levels. We also obtain a gender difference in the level of cooperation when we control for the unobserved heterogeneity of individuals, which indicates that the gender gap in cooperation favoring female students is present after netting out this effect from other socio-demographics factors not controlled for in the experiment, and from gender differences in risk, social and competitive preferences.