I slot the foam and insert common "CA hinges"
EPO you can use normal thin CA.
Other foams you will have to use some other glue. Thin foam-safe CA is good but you can also use epoxy. Gorilla polyurethane glue or any of several other glues...
If desired you can reseal the hinge line with Blenderm (bandage tape) or other tape.
Flexing the foam as the hinge you are guaranteed to eventually crack the foam.