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"

 

 

  • 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
  • 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.

  • 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
  • Hey Raghul, 

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

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

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

    Regards
    Raghul
  • 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

  • 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. 

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

  • 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?