Its hard to tell from the photo. Is this just a case of the covering coming off or is there a fracture in the foam. If there is a fracture in the foam, I can't see the repair area.
Assuming it is a fracture in the foam, one adhesive to consider is a liquid polyurethane base glue. Gorilla, LePages and others make them and every one of them that I have seen is brown. These glues have the distinct advantage that they don't have a solvent carrier so you don't risk them attacking the foam. They require water to cure. If you live in a high humidity area, sometimes the moisture in the air will be sufficient for the cure. The more common practise is just to dampen one of the surfaces to be glued. The wetter the surface, the faster the cure seems to start. Also, these glues tend to foam and expand during the cure. This has the advantage that it can fill small voids. However, too much water and they foam quite a bit (in my experience) and will ooze out with the potential for a mess.
The polyurethane glues are relatively thin bodied (until they start curing) which allows you to work them into the surfaces to be repaired. They have very high adhesion and dry hard. The surfaces to be joined together need to be clamped together to obtain maximum strength. If the surfaces can't be clamped or there is a large gap between the surfaces to be joined, these glues are probably not the best choice. The thicker the glue joint, the weaker the joint. An epoxy putty might be a better option if there is a large gap.
If you use the polyurethane glue and are doing an in situ repair, protect exposed surfaces. If this stuff drips onto the carpet, its unlikely that you would ever get it out of the carpet.