Considerable efforts have been made in search of the genetic basis of human longevity but with only limited progress achieved. One important drawback of current genetic studies on human longevity is the ignorance of gene-environment interaction. Using two cohorts of long-lived individuals born in 1905 and 1915 in Denmark, we performed survival analysis to estimate risk on mortality of major candidate genes of aging and longevity and their cohort effects. Through statistical modelling that combines individual genetic and survival information with cohort-specific survival data, we estimated the relative risks of genetic variants in APOE, FOXO3A, CLU, and PICALM on mortality from age 95 to 103. Our analysis estimated a decreased risk of carrying the APOE ε4 allele (change in risk: -0.403, 95% CI: -0.831-0.021, p=0.040) in males of the later cohort although the allele itself was harmful to survival across sexes (relative risk: 1.161, 95% CI:1.027-1.345, p=0.026). We also estimated a cohort effect of increased risk of the minor allele of rs3851179 in PICALM with borderline significance (change in risk: 0.165, 95% CI: -0.010-0.331, p=0.052) in females. Our estimated significant cohort effect on APOE ε4 is indicative of the interplay between gene and the changing environment that modulates survival at extreme ages.