Cole has been working on his fitness at the Hammers' Chadwell Heath training ground for the past few weeks and successfully came through a behind-closed-doors match against Charlton last week.
The former England international had been a free agent following his release over the summer by West Ham, for whom he originally signed in 2006 and has made 237 appearances, scoring 59 goals.
He was unable to find a new club, and on September 3, the London outfit announced that Cole was undergoing a medical with them with a view to returning on a short-term contract.
No deal subsequently materialised around that time, but on Monday afternoon it was confirmed that the 30-year-old had indeed put pen to paper on a new contract at Upton Park that runs to January 13.
He told West Ham TV: "I'm in an excellent mood, am happy to be back and can't wait to get working with the lads again and start my season off.
"I've been working hard with the strength and conditioning coach Mathew Monte-Colombo in the gym and he's been really hands-on with me to get me up to standard to train with the team and get my match-fitness up as quickly as possible with a view to signing.
"I feel fit and raring to go and it's time to start knocking on the manager's (Sam Allardyce) door to get some games under my belt."
Reflecting on his departure over the summer, Cole added: "At the end of the day, everything happens for a reason and you don't always choose what is going to happen to you.
"We decided to part ways in the summer but West Ham and me have ended up together again. Hopefully I can come in and be who I am and help the team achieve what we need to achieve."