MULTIPLE users in same scenario

My requirement is like one user logs in create somethimg and then other user logs in and updates it.

Feeder is csv as below

User1, user2
1001,4001
1002,4002
1003,4003

Val createProduct =

exec(http("login")
.post("/login")
.formparam("user","${user1}")
.formparam("pwd","5656666"))

.exec{session=>
getCookievalue(CookieKey(XSRF-TOKEN)).saveAs("XSRF-TOKEN")
}

.exec(http("create")
.post("/create")
.header("x-xsrf-token","${XSRF-TOKEN}"
.body())

.exec(http("logout")
.get("logout"))

.exec(http("login2")
.post("/login")
.formparam("user","${user2}")
.formparam("pwd","5656666"))

.exec{session=>
getCookievalue(CookieKey(XSRF-TOKEN)).saveAs("XSRF-TOKEN")
}

.exec(http("update")
.post("/update")
.header("x-xsrf-token",getCookievalue(CookieKey(XSRF-TOKEN))
.body())

.exec(http("logout")
.get("logout"))

Val scenario= Scenario("test").feed(feeder)
.exec(createProduct)

Setup(scenario.inject(rampusers(8) during(10 seconds))

Ignore any typos.

My issue is when the second user logs in and tries to update the product, its getting the XSRF-TOKEN same as from the first user session.

Is there anything i am missing here.

Thanks in advance.

Maybe because you’re fighting against the way Gatling’s virtual users work and using the same virtual user for 2 different “actual” users.
Each Gatling virtual user has its own CookieJar. There’s a good chance your second authentication is ineffective because there’s already a valid cookie.

Try flushing the CookieJar in between: https://gatling.io/docs/current/http/http_helpers/#flushing-all-cookies

Again, enabling DEBUG logging would help you see what happens on the wire.

hi Stephane,

Tried flushing cookies and cache after the first user logs out, but still its not working.

Any other options pls.

Thanks

I’m positive the issue isn’t with Gatling but either with your test or your application.
Can’t do more than this, as I pointed out, you should lower logging level and start debugging what happens on the wire.