Considerable efforts have been made to identify the genetic basis of human longevity, with only limited progress. One important drawback of current genetic studies is the limited knowledge of gene-environment interaction. Using 2 cohorts of long-lived individuals born in 1905 and 1915 in Denmark, we performed survival analysis to estimate risk of mortality for major candidate genes of aging and longevity and their cohort effects. Through statistical modeling that combines individual genetic and survival information with cohort-specific survival data, we estimated the relative risks of mortality from ages 95 to 103 years associated with genetic variants in apolipoprotein E (APOE), forkhead box class O3a, clusterin, and phosphatidylinositol binding clathrin assembly protein. Our analysis estimated a decreased risk of carrying the APOE$\varepsilon $4 allele (change in risk = -0.403, 95% confidence interval (CI): -0.831, 0.021; P = 0.040) in men 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 for the minor allele of rs3851179 in phosphatidylinositol binding clathrin assembly protein with borderline significance (change in risk = 0.165, 95% CI: -0.010, 0.331; P = 0.052) in women. Our estimated significant cohort effect on APOE$\varepsilon $4 is indicative of the interplay between the gene and the changing environment that modulates survival at extreme ages.