A.G.
My 3 yr old is sometimes this way. She is becoming shy, even around people she knows. And she is also clingy at what seems to be random times or days. My older daughter did not go through this phase, so this is new for us. But, I'm actually enjoying it. She wasn't a very clingy baby, so this clingy-ness is fun for me now....even though I do have an 18 month old that is NOT liking this. :) I think it's because they are becoming more aware of things - dangers, strangers, being alone, etc. They're just trying to figure out when they feel safe and how to keep feeling safe.
Maybe offer a little extra snuggle time when he'll let you and be sure to explain when you'll be back or where you're going....just some reassurance. My 3 yr old cried once at school for a few seconds a few weeks ago (first time for her), which made me sad. But I just explained this was our routine and that I'd be back for her in a few hours.
Good luck!