How to get 2 year old to stop spitting.

Everytime I give him a cup he takes a couple drinks, then he will drink and spit it out.

I've tried ignoring it, time outs, taking the cup away.

I'm worried about his hydration levels because he is constantly spitting it out.