The boy's mother accidentally locked her keys in the car, along with her son and her pet dog.
She immediately called police.
Temperatures in Palmdale were close to 100 degrees.
The boy finally got out after being trapped for about 30 minutes.
Police say he is doing fine.
The mother is not expected to be charged.