extract session setting block into a private method