Generalize some session modification functions.