I did this with both my Iron Man Mk 6 suit and war machine suit. I did a lot of experimenting with your standard neodynium magnets to figure out what they were and weren't suited for. the main things i used them for was the knee joint of iron man, and holding the chestplate and backplate onto the internal torso brace, like so:
I used duct tape and hot glue to keep the magnets in the cutouts i made for them. when it comes to EVA foam, putting hot glue down and duct tape over it created the absolute STRONGEST bond possible, stronger than the foam itself honestly. That's CPO Mendez's secret recipe.
To figure out how to position the neodynium magnets on the outer pieces so that they lined up EXACTLY with the brace inside the chest, i traced the magnet on the brace where i wanted it, after positioning the brace inside the chest and back piece, and then used a small nail to poke holes through the brace and into the back/chest pieces on the other side:
Overall, the neodynium magnets were great at holding the pieces together, however they really just couldn't hold together completely with the shifting forces of my body (things like turning, moving around, bending over, even just the movements of walking) and honestly nothing really beats nylon straps and buckles. i ended up having to add them to the bottom front of the brace, since the LED "arc reactor" needed to line up with the hole in the chestpiece:
Now for the knee joints: they actually had a really good unintended effect. Like i said before, the magnets will disengage with enough force. however, with the knee joint of the Mk. 6, it allowed me to bend down and take a knee (which, if you've ever cosplayed and done pictures, you should know is INSANELY useful for the little kids that want pictures) however, given the nature of foam, its hard to get it into the perfect position for a rotating knee joint like that, so the plastic on the bottom of the thigh piece that held the other magnet had a tendency to shred the little circular foam piece on the calf:
And here's what the thigh part of the joint looks like (the blue is from a character mashup paintjob i did, same suit though)
And the damage i mentioned:
Hope this helps! i did a few more things with magnets, so if you have any more questions i'll be happy to answer.