If magnets are glued to metal:
Use JB WELD (aluminum filled) or Devcon Plastic Steel Epoxy (steel filled).
If magnets are glued to plastic:
Use flexibilized cyanoacrylate (like Loctite 4902, MasterBond MB297FL), flexibilized epoxy (like SikaPower®-1200), or last but least - retail moisture curing polyurethane (gorilla glue),
Sorry, many of those are commercial materials, and will require sourcing from an online distributor like Ellsworth Adhesives, or similar.
They key to strong bond:
- Must have rough surfaces, and increased surface area for strongest bond.
No shinny surfaces. Use 40-80 grit sand paper and make both surfaces rough.
- Must be clean!
Mechanically remove any trace of old adhesive, dirt, oils, etc. Then clean with little soapy water for water soluble stuff. Next clean with lacquer thinner (mix of acetone, hydrocarbon, and ester solvents). Let dry thoroughly.
- Wet surface will reduce adhesion and bond strength - except polyurethane.
If humidity is over 50% RH, need to bake moisture off the surface. Pre-bake the parts in oven at 140F for 2 hours to remove all surface moisture. Must bond the surfaces in less than 20 minutes or when they reach room temp, else bake and start over. Some adhesives are more tolerant of moisture, but they work best with dry surface. Ignore this tip for Gorilla Glue
FWIW - Devcon Plastic Steel (thicker putty version) sticks like grime death to properly prepared steel surfaces. You can grind, machine, and even tap threads into it when fully cured. Great for repairing cast iron or other pot metal parts.
PS - not an expert, just sharing what has worked in past for me.
Maybe not entirely true? I have worked with adhesives and polymers for over 30yrs professionally. But, I am still an idiot klutz.
Best Luck!