After boarding is more or less complete but before the door has closed, I routinely ask an FA if it's OK to take a pic of the cockpit. With only 1 exception (a decidedly unhappy and generally unpleasant FA on a UA flight) the answer has always been yes.
I go up to the cockpit, say hi to the pilot & co-pilot, take 2 or 3 quick pics then go back to my seat. It's no big deal.
I think though if I had my cool little (2.5y old) nephew in tow, I would wait until after we had landed and most people had deplaned.
Common sense folks - be polite, be quick, don't interfere / get in the way.