I have found success using several different adhesives available in caulking style tubes. The one I am using now is a DAP product called ALL-PURPOSE, BEATS the NAIL construction adhesive. Any Home depot/Lowes type outlet will stock this @ around $3 a tube. Obviously you will need a caulking gun too.
Regarding the use of hot glue mentioned above...I'd be wary of that since the heat is going to melt/deform the foam and make a mess unless there is a method of using it in this application I am unaware of. Just my thoughts.
Bob