Get _id of inserted row and store in session

@iaindowner give it a try, it seems OK - although I haven’t tested the code