Use session cookies when following redirects

A fix for issue #1228.

I have a nagging feeling, that there'd be a better way to do this, but here goes.