John Lauder (d.1710), 5th Earl of Lauderdale, Lord of Session