Help need for parsing a session token which is provided as part of query params in response

Hi Team,

I am newbie to Gatling and I am struggling to parse the session returned for my http post request.I am using New Gatling version 2.2.4

Please find my request and response and suggest me how to extract the session token value and parse it other requests.

Request:

val customerlogin = exec(http(“customerlogin”)
.post("/user/customerlogin?deviceName=iphone&deviceType=phone&modelNo=6s&serialNo=12345678&lang=en_US")
.formParam(“operator”, “HBO-GO”)
.formParam(“email”, “${userName}”)
.formParam(“password”, “password1”)
.formParam(“returnURL”, “/user/success”)
.formParam(“deviceName”, “iphone”)
.formParam(“deviceType”, “phone”)
.formParam(“modelNo”, “6s”)
.formParam(“serialNo”, “12345678”)
.get("/user/success?sessionToken").saveAs(sessionToken)
)

Response :

HTTP response:
status=
302 Found
headers=
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Content-Type: text/html; charset=UTF-8
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Location: /user/success?sessionToken=VC6d-uayB-Kes3-os6M-YuDo-0SSj-DK&channelPartnerID=HBO_Asia&lang=en_US
Pragma: no-cache
Server: Apache/2.4.25 (Amazon) PHP/5.6.29
Set-Cookie: PHPSESSID=0bgu3oktlia2vtg5r9kv0jigj2; path=/
Set-Cookie: locale=en_US
X-Powered-By: PHP/5.6.29
Content-Length: 0
Connection: keep-alive

I want the value in the sessionToken to be parsed to another request. Need your help to get knowledge on how to deal with this problem.

Thanks in Advance
Vivek

Hello,

My solution to this case is something like this:

var sessionToken :String = “”

val customerlogin = exec(http(“customerlogin”)
.post(“/user/customerlogin?deviceName=iphone&deviceType=phone&modelNo=6s&serialNo=12345678&lang=en_US”)
.formParam(“operator”, “HBO-GO”)
.formParam(“email”, “${userName}”)
.formParam(“password”, “password1”)
.formParam(“returnURL”, “/user/success”)
.formParam(“deviceName”, “iphone”)
.formParam(“deviceType”, “phone”)
.formParam(“modelNo”, “6s”)
.formParam(“serialNo”, “12345678”)

.exec(session => {
sessionToken= session.get(“sessionToken”).as[String]
session
})

.exec(http(“nextRequest”)
.post(session => “/someurl” + sessionToken + “/voyages”))

Hi Emre Yildirim,

Thanks for the help , currently we have hard coded the url to get the session with currentLocationRegex

currentLocationRegex(“https://www.website.com/user/success?(.)=(.)”).ofType[(String,String)]