Simulate the login state using cookie

Hey there,

I have tried to simulate the stated of logged in user by adding a cookie like so

exec(addCookie(Cookie(“sso2”, “${USERID}_$(RandomKey)_sn2_ts1430149950239”)))
.exec(
http(“Search Flow login”)
.get("${URL}")
.check(status.is(200))
.check(regex(“Sign out”))
)

However, it doesn’t look like the user is logged in after insert the cookie as it fails on the regex check on the page. Should I have used something other than ‘addCookie’ to simulate cookie insertion?

Thanks :slight_smile:

Gatling will auto append cookies in subsequent request. I’d recommend you uncomment the following line in logback-test.xml file so you can see what http response you get along with the cookies being set.

`

`

Most server applications are stateful and cookies match some Session memory space on the server.
Are you sure that your cookies can be replayed like this?