Add cookie support

As the title says. Still needs testing.