helper function for view/update session variables.