Don't use WD 40 for protection on firearms. It's not that it won't work okay, but rather given enough time and heat it can start to varnish up in crevices (like say inside the firing pin channel) It'll work in a pinch though, and if your gun gets soaked in rain it's one of the best products to use to displace the moisture and lightly protect the metal short term. The most important thing is regular maintenance.
I've used ... LOTS of various products ranging from wd40 to motor oil to japanese sword oil to boutique gun and knife lubricants. The thing is on a regularly carried item holster/pocket/handling will remove the protection in a fairly short period of time. Reoil the outside surfaces after handling or at the end of the day if you use them, and you can use practically any oil out there.
Regarding favorite/worst products. I like Weaponshield CLP for general purpose lubrication and protection. Fantastic lubricant, good but not great protection. Militec 1 is another popular product, I dislike it for a number of reasons. Regardless of any ad copy its not good at protecting steel in the presence of moisture. Breakfree CLP is a long time standby, okay lubricant and good corrosion protection. Ballistol is okay stuff but smelly as all get out.
If WD 40 is what you have though, then use it. Just don't spray it into firing pin channels or tight fitting moving parts. If you want a cheap general purpose lube that you can get locally, Mobil 1 0w40 and synthetic ATF's work better than most of the gun oils out there. Don't over lube, apply a thin film and wipe off the excess.