session functions updated to use session object