#1803·hurl

Feature proposal: Support for multiple independent cookie jars in a single Hurl file

Author: willbicksCreated Jul 29, 2023Updated Jul 28, 2026
Labelsenhancement

Problem to solve

I'm looking to use Hurl to create some tests for an server-side rendered PHP webapp. Using http basic auth I can authenticate a user, and during authentication a session cookie is set to identify their session. Future requests in the same Hurl file can act as that user so long as those requests carry the Auth and Cookie headers.

The challenge is, I'm trying to test behaviors that span multiple users of the application. For example, I'd like to emulate an admin making a change, then a different user making a request, and then the admin making a different change, and back and forth. Unfortunately, since Hurl always stores all cookies in one jar, I can't emulate more than one signed in user in a single Hurl file. I could theoretically create a new Hurl file for each step of my test, but then ordering becomes a challenge, and I have to repeat a lot of login logic in each file.

Proposal

It would be great if I could establish multiple independent cookie jars to simulate multiple users of the application in a single hurl file. For example, named cookie jars could be specified in the [Options] section:

# Login as user1 and store their session in a cookie jar labeled user1
GET {{baseURL}}/login
Authorization: {{authUser1}}
[Options]
cookie-jar: user1

# Perform an action as user1
POST {{baseURL}}/foo
Authorization: {{authUser1}}
[Options]
cookie-jar: user1
[FormParams]
title: "Hello World!"

# Login as user2 and store their session in a cookie jar labeled user2
GET {{baseURL}}/login
Authorization: {{authUser2}}
[Options]
cookie-jar: user2

# GET content as user2
GET{{baseURL}}/foo
Authorization: {{authUser2}}
[Options]
cookie-jar: user2

... and so on, testing other changes while seamlessly switching users

Additional context and resources

I tried manually capturing and tracking cookies in variables to emulate this behavior, but this only works when using the undocumented @cookie_storage_clear option.

GET {{baseURL}}/login
Authorization: {{authUser1}}
[Captures]
authUser1Session: cookie "session"

POST {{baseURL}}/foo
Authorization: {{authUser1}}
[Cookies]
session: {{authUser1Session}}
[FormParams]
title: "Hello World!"

# @cookie_storage_clear
GET {{baseURL}}/login
Authorization: {{authUser2}}
[Captures]
authUser2Session: cookie "session"

If if fit with the Hurl project's goals, it would be even easier if Hurl had higher level support for multiple actors or users, so that each actor could have it's own Authorization header and cookie jar, and each request could be simply labeled with something like actor: userX. That I imagine is a bit of a bigger proposal, but I'd be interested to hear if it's a good direction.

Tasks to complete

  • ...