Stellar activity has a particularly strong influence on planets at small orbital distances, such as close-in exoplanets. For such planets, we present two extreme cases of stellar variability, namely stellar coronal mass ejections and stellar wind, which both result in the planetary environment being variable on a timescale of billions of years. For both cases, direct interaction of the streaming plasma with the planetary atmosphere would entail servere consequences. In certain cases, however, the planetary atmosphere can be effectively shielded by a strong planetary magnetic field. The efficiency of this shielding is determined by the planetary magnetic dipole moment, which is difficult to constrain by either models or observations. We present different factors which influence the strength of the planetary magnetic dipole moment. Implications are discussed, including nonthermal atmospheric loss, atmospheric biomarkers, and planetary habitability.