Updated with code from website. Battling to convert between array objects in session and json objects. Grrh.