# How to Retrieve SessionAttribute

**URL:** <https://community.gatling.io/t/how-to-retrieve-sessionattribute/3884>\
**Category:** Gatling (Open-Source)\
**Created:** [August 14, 2017, 3:36pm UTC](https://community.gatling.io/t/how-to-retrieve-sessionattribute/3884 "2017-08-14T15:36:02Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![leela\_krishna](https://avatars.discourse-cdn.com/v4/letter/l/35a633/32.png) [@leela\_krishna](https://community.gatling.io/u/leela_krishna)\
**Post date:** [August 14, 2017, 3:36pm UTC](https://community.gatling.io/t/how-to-retrieve-sessionattribute/3884/1 "2017-08-14T15:36:02Z")

</div>

I’m still unable to parse the session value stored in one request into other.  
I’ve two http requests  
val scn = scenario(“Device”)  
.feed(csvFeeeder)  
.exec(http(“Auth Header gene)  
.post(”/auth")  
.headers(headers\_0)  
.formParam(“type”, “device”)  
.check(headerRegex(“auth”,“device\*”).saveAs(“authH”))  
.check(status.is(401)))

.exec(http(“Signed Req”)  
.post("/auth/oauth")  
.headers(Map(  
“x-id” → “${id}”,  
“x-serial” → “${serial}”,  
“Authorization” → test.dummy))  
.formParam(“type”, “device”))

the test.dummy is a function which converts the saved string “authH” into some format and that converted output needs to be passed to the “Authorozation” header in my second request. for that purpose I’m using something like this

object test{  
def dummy: String = {  
val = (Here I need to get the saved authH session attribute)  
— logic to convert into my required format–  
return convertedString  
}  
}

I was unable to get the sessionAttribute there. Is there a way to get the sessionAttribute. Please HELP. I go through the Gatling documentation but could not find any solution

---

<div class="post-metadata">

**Author:** ![Jay\_Kelner](https://avatars.discourse-cdn.com/v4/letter/j/47e85d/32.png) [@Jay\_Kelner](https://community.gatling.io/u/Jay_Kelner)\
**Post date:** [August 14, 2017, 7:28pm UTC](https://community.gatling.io/t/how-to-retrieve-sessionattribute/3884/2 "2017-08-14T19:28:00Z")

</div>

try “Authorization” → test.dummy("${authH"})

& let dummy take param

---

<div class="post-metadata">

**Author:** ![leela\_krishna](https://avatars.discourse-cdn.com/v4/letter/l/35a633/32.png) [@leela\_krishna](https://community.gatling.io/u/leela_krishna)\
**Post date:** [August 14, 2017, 7:51pm UTC](https://community.gatling.io/t/how-to-retrieve-sessionattribute/3884/3 "2017-08-14T19:51:14Z")

</div>

I tried passing the saved value as method parameter. But still, it did not work. I got 403. I should get a 200

---

<div class="post-metadata">

**Author:** ![leela\_krishna](https://avatars.discourse-cdn.com/v4/letter/l/35a633/32.png) [@leela\_krishna](https://community.gatling.io/u/leela_krishna)\
**Post date:** [August 15, 2017, 1:11pm UTC](https://community.gatling.io/t/how-to-retrieve-sessionattribute/3884/4 "2017-08-15T13:11:11Z")

</div>

I tried to print the parameter value in the test method. But, it just prints ${authH}

---

<div class="post-metadata">

**Author:** ![leela\_krishna](https://avatars.discourse-cdn.com/v4/letter/l/35a633/32.png) [@leela\_krishna](https://community.gatling.io/u/leela_krishna)\
**Post date:** [August 15, 2017, 1:23pm UTC](https://community.gatling.io/t/how-to-retrieve-sessionattribute/3884/5 "2017-08-15T13:23:17Z")

</div>

Is there anyway, that I can create a sessionAttribute object in my function and get the saved session attribute through that object?

---

<div class="post-metadata">

**Author:** ![Jay\_Kelner](https://avatars.discourse-cdn.com/v4/letter/j/47e85d/32.png) [@Jay\_Kelner](https://community.gatling.io/u/Jay_Kelner)\
**Post date:** [August 15, 2017, 6:35pm UTC](https://community.gatling.io/t/how-to-retrieve-sessionattribute/3884/6 "2017-08-15T18:35:25Z")

</div>

are you using  
**"** ${authH} **"**

or

**s"** ${authH} **"**

or

**"""** ${authH} **"""**

---

<div class="post-metadata">

**Author:** ![leela\_krishna](https://avatars.discourse-cdn.com/v4/letter/l/35a633/32.png) [@leela\_krishna](https://community.gatling.io/u/leela_krishna)\
**Post date:** [August 15, 2017, 6:47pm UTC](https://community.gatling.io/t/how-to-retrieve-sessionattribute/3884/7 "2017-08-15T18:47:31Z")

</div>

I’m using “${authH}”. Anyway I am able to retrieve the session attribute like this  
.header(“Authorization” , session=\>test.dummy(session(“authH”).as[String]))
