session should be a pointer to sp_session.