0
votes

I am sending a list of http request through Python. My list of request contains a login url for which I am passing username, password and other required information. Using this I am able to login to site.

response = self.client.post('login.aspx',{parameters})

Now after login I am getting the sessionId in cookies. I am extracting this sessionId by using the following:

self.client.cookie.items()

Now, how I can add this sessionId in next request header and send this request to server, so that current user's session will maintain as it is?

My execution is like.... .Net code -> execution of 1st request in 1st python file -> .net code execution -> execute 2nd request in 2nd python file -> .net code -> 3rd request in 3rd python file -> so on...so in this case session is not get maintain...thats why I am trying to pass sessionId from first request to second request header...So how can I do this?

1

1 Answers

0
votes

When you inherit from the HttpLocust class and use its client attribute to make http requests, the session should be kept alive automatically between requests which means that you do not need to explicitly set the sesssion id in the header of the next request

You can read the documentation at : http://docs.locust.io/en/latest/writing-a-locustfile.html#making-http-requests