I think it's largely a question of luck. As far as I am aware, the "cockpit visit" rules are airline-dependent (although I am happy to be corrected on this); my boyfriend's a skipper and I know that even
he is not allowed to jumpseat on flights he isn't crewing - that's how stringent the rules are in his company. Cockpit visits during flight = instant dismissal. However, other airlines appear to have different rules.
I fly a lot with a certain (East African) airline and am always jumpseating
Maybe your "luck" in this department is down to you being an ATC student? If I recall correctly, quite a number of airlines are happy to allow ATCOs and ATC students to jumpseat.