I agree with using the diodes. I usually buy the 1N4001 - 1N4004; they are 1 amp in various voltages. 1N5401 (and up) are 3 amp, and hence a little heavier.
For quick, easy availability of parts I'll stop by Radio Shack. Something like these should work:
1N4001: 276-1653 (25 pack)
1N5402: 276-1143 (each)
Otherwise, I buy online either from Mouser (
www.mouser.com) or Digikey (
www.digikey.com). There are lots of other good online sources as well. Mouser is "just down the road a piece" from me, so ground shipping comes overnight (but not free). It's too far to drive, though.
In use, the diode will be reverse biased (off, non-conducting). When the magnetic field collapses, the voltage will reverse and flow thru the diode, which will absorb the spike. The spike will not only burn out bulbs, but also arc across switch contacts and eventually burn up whatever is controlling the solenoid.
Now: for the curious, what are you doing with the solenoids? What is this machine? Pictures?