Use calendar.timegm when calculating cookie expiration

Fixes #1859

Credit: @lukasa