Costco recorded a rise in second-quarter net income as the US warehouse club's results were boosted by strong sales and higher gas prices.