engine ligjt on 2006 Chevrolet Cobalt

My check engine light coming on when gas tank gets half empty. I get gas and tighten cap and goes off after a 30 mile drive. Went to auto zone and advance auto and no code shows up. What could be the problem

Asked by for the 2006 Chevrolet Cobalt
Get the code read while the light is still on and post the code here. The actual code (ie.P0411, or what ever it is) is much more useful than what the guy at AutoZone tells you. People will be better able to help with the actual code.
1 more answer
it becomes a history code when the light goes out. a shop with a real scan tool can acess the history codes and can identify the system failure and the problem as well.