Highlighted
Established Member..
Established Member..
7121 views

Capture cookie value passed in the header for a particular request

Hi All, 

I am trying to capture a cookie value passed in the header of a particular HTTP request and I am not able to do so. There are two cookie being passed. One of them is the SESSION ID that is being carried from the login and there is additional cookie that is required to authenticate a report I am trying to open. I have tried all functions to capture the value of that cookie, but somehow its looking for the SESSION ID cookie that is being captured already. Please tell me how to do this. 

Here is the header 

POST /nutrition-reports/frameset HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Referer: https://*****.abc.com/app/display_report.zul
Cookie: JSESSIONID={c_dtCookie}
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.8
Accept: */*
Connection: Keep-Alive
Host: my*****.***.com
Cookie: JSESSIONID=E3E86B2BDCA9B0CDF197CC79EB702E77.cguschd2728vm
Content-Length: 1619

and here is the code I am trying to capture and insert just before the request

web_reg_save_param_ex("ParamName=c_dtCookie",
"LB=JSESSIONID=",
"RB=.cguschd2728vm",
SEARCH_FILTERS,
"Scope=All",
LAST);

web_add_header("Cookie","JSESSIONID={c_dtCookie}");

I need to capture this cookie "Cookie: JSESSIONID=E3E86B2BDCA9B0CDF197CC79EB702E77.cguschd2728vm"

 

 

0 Likes
10 Replies
Highlighted
Honored Contributor.
Honored Contributor.

Re: Capture cookie value passed in the header for a particular request

Hi,
You can cleanup the cookies using the functions to generate automatically .jsessionid is common in Java applications.if you want to capture the jsessionid, replay with data returned by server option and check with variable name jsessionid in the replay log.it will be in some response header

Regards
Raghul
0 Likes
Highlighted
Established Member..
Established Member..

Re: Capture cookie value passed in the header for a particular request

Hey Raghu, 

Thanks for the response. I tried to clean up cookies before and it didn't work, so I decided to capture this SESSION ID. The reason I am capturing is because I am getting "401 Unauthorized error" for a request that is opening a report on a Tomcat servers. 

As you can see above in the code, the session id cookie  being passed is in the request header, not response header. It's an additional cookie that is being passed for that request and it has the same boundaries as the other SESSION ID I have.

0 Likes
Highlighted
Honored Contributor.
Honored Contributor.

Re: Capture cookie value passed in the header for a particular request

Hi

you are trying capture the jsessionid from the request where it is hard coded. it's passing as {session I'd}.

Post the replay log with data returned by server. Will check and let you know asap.

Meanwhile post both recorded and replayed request from snapshot raw data

Regards
Raghul
0 Likes
Highlighted
Established Member..
Established Member..

Re: Capture cookie value passed in the header for a particular request

Hey Raghul, 

Thanks a lot for quick response. Attaching the log files you asked for.

0 Likes
Highlighted
Established Member..
Established Member..

Re: Capture cookie value passed in the header for a particular request

Forgot to mention. Change the extension ".jpg" to ".txt" for the files attached. The forum wasn't allowing me to attach text files. 

0 Likes
Highlighted
Honored Contributor.
Honored Contributor.

Re: Capture cookie value passed in the header for a particular request

I couldn't check the file from my mobile. Will see tomorrow and let you know about it

Regards
Raghul
0 Likes
Highlighted
Honored Contributor.
Honored Contributor.

Re: Capture cookie value passed in the header for a particular request

Hi,

You have captured the Jsession ID correctly as per the replay log from URL web_url("app"). but the parameter "dtid" is correlated below the "app" request and substitued wrongly in the URL web_url("app"). The substitution of dtid value in URL https://xxx.xxx-xxx.com/app/zkau?dtid={dtid3}&cmd_0=rmDesktop&opt_0=i seems to be the problem in loading the PDF. And also referer and Content Type(wrongy sent while replaying) is not there in Frameset URL which is throwing 401 Unauthorised Error Code. Please do verify your script and make the above changes and let me know if you are facing the same.

.c(63): Notify: Parameter Substitution: parameter "c_JSessionID" =  "163615F1AE96634A969265D50DFFD3E6.cguschd2729vm"
Login.c(63): Warning: The string 'dtid' with parameter delimiters is not a parameter.

Even the URL is not posted correctl which is causing the frame URL unable to get the proper response for the wrong request sent. The below highlighted Request Headers are not sent properly which is not giving proper response.


POST /nutrition-reports/frameset HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Referer: https://xxx.xxxx-xxx.com/app/display_report.zul
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.8
Accept: */*

 

Regards,

Raghul M

0 Likes
Highlighted
Established Member..
Established Member..

Re: Capture cookie value passed in the header for a particular request

Hi Ragul, 

Thanks so much for responding. I am attaching the LR script. The suggestions you made may not work because I checked the fiddler responses and the paramaterization and everything else like Content-type, looks fine to me. I am sending you script to see if you can find some mistake. I don't know LoadRunner at expert level. 

HOwever, I do want to tell yo u that when I unchecked "simulate new Vuser on each iteration" , i am getting http 500 Internal server error instead of 401 for that request. The original request goes to the app server and then that frameset URL is sent to the Tomcat server and may be that Tomcat server is generating its own session ID, but its not recognized by the app server. 

0 Likes
Highlighted
Established Member..
Established Member..

Re: Capture cookie value passed in the header for a particular request

Any luck Raghul? I tried your suggestion, but no luck sofar. 

0 Likes
Highlighted
Visitor.

Re: Capture cookie value passed in the header for a particular request

Hi,

Were you able to resilve the issue, actually I am also facing exactly same issue and not able to proceed further.

If you found the solution, could you please help me with this?

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.