I know on the airline my boyfriend flies for that cockpit visits are permitted whilst on the ground, and as long as it's before the doors are closed / push back. Obviously, in-flight cockpit visits are a complete no-no but in the case of his particular airline that rule came in long before 9/11 (can't go into it on here). If I'm on a flight he's skippering I almost always go down early and sit in the jumpseat while he and the F/O prepare for the flight, until we push back.
You should definitely ask; I've never been refused a cockpit visit on the ground before, or after, the flight - and frequently fly jumpseat here in Africa (where rules are made to be broken!).