Discussion:
Insert Cookies for some requests in a thread group
henryd
2008-09-28 06:31:41 UTC
Permalink
I am testing a rich ajax application. I recorded using "http watch" and
trying to add all these https requests in Jmeter and I am having trouble in
playing it successfully. One of the problem I am having is that some
requests involve java scripts on that specific page sending new cookies
with the same domain. It seems I can only have one cookie manager per thread
group. I tried to have several simple controllers with their cookie managers
and that obviously does not work.

How can I add my own cookies for some requests. If I add it to the cookie
manager at the thread level, these cookies get added to all requests.

Sincerely appreciate your help.
--
View this message in context: http://www.nabble.com/Insert-Cookies-for-some-requests-in-a-thread-group-tp19709256p19709256.html
Sent from the JMeter - User mailing list archive at Nabble.com.
Laurent Perez
2008-09-28 08:35:15 UTC
Permalink
Post by henryd
How can I add my own cookies for some requests. If I add it to the cookie
manager at the thread level, these cookies get added to all requests.
I believe you can use
http://jakarta.apache.org/jmeter/usermanual/component_reference.html#HTTP_Header_Manager
at the HTTP Request level (instead of Thread group level).

So I guess you could create a header named Cookie for each request. If
cookies values need to be dynamic ones, you could use some post
processor to extract Set-cookie values from the response and store
them as variables.

Don't know if this would fit your needs, I never tried this.

laurent
Post by henryd
Sincerely appreciate your help.
--
View this message in context: http://www.nabble.com/Insert-Cookies-for-some-requests-in-a-thread-group-tp19709256p19709256.html
Sent from the JMeter - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
--
<a href="http://in-pocket.blogspot.com">http://in-pocket.blogspot.com
- Mobile world, technology and more</a>
henryd
2008-09-28 14:38:51 UTC
Permalink
I have tried adding "Cookie" as a header and jmeter does not treat it as
cookie and that does not appear in the outgoing request. I wish I could use
additional "Cookie Managers" in addition to adding at thread level to add
extra cookies or change cookies to what I am getting by adding it at the
thread level.
Post by Laurent Perez
Post by henryd
How can I add my own cookies for some requests. If I add it to the cookie
manager at the thread level, these cookies get added to all requests.
I believe you can use
http://jakarta.apache.org/jmeter/usermanual/component_reference.html#HTTP_Header_Manager
at the HTTP Request level (instead of Thread group level).
So I guess you could create a header named Cookie for each request. If
cookies values need to be dynamic ones, you could use some post
processor to extract Set-cookie values from the response and store
them as variables.
Don't know if this would fit your needs, I never tried this.
laurent
Post by henryd
Sincerely appreciate your help.
--
http://www.nabble.com/Insert-Cookies-for-some-requests-in-a-thread-group-tp19709256p19709256.html
Sent from the JMeter - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
--
http://in-pocket.blogspot.com http://in-pocket.blogspot.com
- Mobile world, technology and more
---------------------------------------------------------------------
--
View this message in context: http://www.nabble.com/Insert-Cookies-for-some-requests-in-a-thread-group-tp19709256p19712078.html
Sent from the JMeter - User mailing list archive at Nabble.com.
sebb
2008-09-28 16:16:31 UTC
Permalink
No need to use multiple cookie managers - anyway, they won't work.

If the server sets a cookie, it will be seen by JMeter (unless you are
using redirect automatically), and JMeter will send any relevant
cookies with the next request.

If you want to add your own cookies, add them to the cookie manager.
But this is rarely needed.

Note that there was a problem in 2.3.1 if you selected "Clear cookies
each iteration".

Upgrade to 2.3.2 if necessary.
Post by henryd
I have tried adding "Cookie" as a header and jmeter does not treat it as
cookie and that does not appear in the outgoing request. I wish I could use
additional "Cookie Managers" in addition to adding at thread level to add
extra cookies or change cookies to what I am getting by adding it at the
thread level.
Post by Laurent Perez
Post by henryd
How can I add my own cookies for some requests. If I add it to the cookie
manager at the thread level, these cookies get added to all requests.
I believe you can use
http://jakarta.apache.org/jmeter/usermanual/component_reference.html#HTTP_Header_Manager
at the HTTP Request level (instead of Thread group level).
So I guess you could create a header named Cookie for each request. If
cookies values need to be dynamic ones, you could use some post
processor to extract Set-cookie values from the response and store
them as variables.
Don't know if this would fit your needs, I never tried this.
laurent
Post by henryd
Sincerely appreciate your help.
--
http://www.nabble.com/Insert-Cookies-for-some-requests-in-a-thread-group-tp19709256p19709256.html
Sent from the JMeter - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
--
http://in-pocket.blogspot.com http://in-pocket.blogspot.com
- Mobile world, technology and more
---------------------------------------------------------------------
--
View this message in context: http://www.nabble.com/Insert-Cookies-for-some-requests-in-a-thread-group-tp19709256p19712078.html
Sent from the JMeter - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
henryd
2008-09-29 13:07:21 UTC
Permalink
It is still not working for me. I have a cookie manager at the thread group
level for all my 20 requests. I added a "cookie manager" as a child for one
request and added two cookies to it. These cookies are not being sent along
with my request. They get sent only if I disable the main "cookie manager"
at the thread group level. I am stuck as it appears like Jmeter does not
support adding a browser cookie for one request in my thread group, when I
want the server cookies for all the rest of my requests.
Post by sebb
No need to use multiple cookie managers - anyway, they won't work.
If the server sets a cookie, it will be seen by JMeter (unless you are
using redirect automatically), and JMeter will send any relevant
cookies with the next request.
If you want to add your own cookies, add them to the cookie manager.
But this is rarely needed.
Note that there was a problem in 2.3.1 if you selected "Clear cookies
each iteration".
Upgrade to 2.3.2 if necessary.
Post by henryd
I have tried adding "Cookie" as a header and jmeter does not treat it as
cookie and that does not appear in the outgoing request. I wish I could use
additional "Cookie Managers" in addition to adding at thread level to add
extra cookies or change cookies to what I am getting by adding it at the
thread level.
Post by Laurent Perez
Post by henryd
How can I add my own cookies for some requests. If I add it to the
cookie
Post by Laurent Perez
Post by henryd
manager at the thread level, these cookies get added to all requests.
I believe you can use
http://jakarta.apache.org/jmeter/usermanual/component_reference.html#HTTP_Header_Manager
Post by Laurent Perez
at the HTTP Request level (instead of Thread group level).
So I guess you could create a header named Cookie for each request. If
cookies values need to be dynamic ones, you could use some post
processor to extract Set-cookie values from the response and store
them as variables.
Don't know if this would fit your needs, I never tried this.
laurent
Post by henryd
Sincerely appreciate your help.
--
http://www.nabble.com/Insert-Cookies-for-some-requests-in-a-thread-group-tp19709256p19709256.html
Post by Laurent Perez
Post by henryd
Sent from the JMeter - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
--
http://in-pocket.blogspot.com http://in-pocket.blogspot.com
- Mobile world, technology and more
---------------------------------------------------------------------
--
http://www.nabble.com/Insert-Cookies-for-some-requests-in-a-thread-group-tp19709256p19712078.html
Sent from the JMeter - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
---------------------------------------------------------------------
--
View this message in context: http://www.nabble.com/Insert-Cookies-for-some-requests-in-a-thread-group-tp19709256p19723533.html
Sent from the JMeter - User mailing list archive at Nabble.com.
sebb
2008-09-28 22:57:52 UTC
Permalink
Sorry, if I did not make myself clear. I am using "2.3.2.r665936". I am not concerned about the cookies sent by server in this case. The javascripts on my web pages set some cookies for certain requests resulting in browser sending a request to the server with this new cookie or a different value for the same cookie. This is where I am having real problem. Is there any way to send a specific cookie for a couple of requests in my thread group where I have 20 requests all together.
Yes, if you want to ignore server cookies, just add the cookie manager
as a child of each request that needs the specific cookies.
BTW, what happens when I set "automatic redirection" and the server sets a new cookie and issues a 302 and the subsequent request goes to the redirected url with this new cookie. Will this work in Jmeter or do I need to create two different requests instead of setting "automatic redirection".
No and no - please see:

http://jakarta.apache.org/jmeter/usermanual/component_reference.html#HTTP_Request

See "Redirect Automatically" and "Follow Redirects"
Post by sebb
No need to use multiple cookie managers - anyway, they won't work.
If the server sets a cookie, it will be seen by JMeter (unless you are
using redirect automatically), and JMeter will send any relevant
cookies with the next request.
If you want to add your own cookies, add them to the cookie manager.
But this is rarely needed.
Note that there was a problem in 2.3.1 if you selected "Clear cookies
each iteration".
Upgrade to 2.3.2 if necessary.
Post by henryd
I have tried adding "Cookie" as a header and jmeter does not treat it as
cookie and that does not appear in the outgoing request. I wish I could
use
additional "Cookie Managers" in addition to adding at thread level to
add
extra cookies or change cookies to what I am getting by adding it at the
thread level.
Post by Laurent Perez
Post by henryd
How can I add my own cookies for some requests. If I add it to the
cookie
Post by Laurent Perez
Post by henryd
manager at the thread level, these cookies get added to all requests.
I believe you can use
http://jakarta.apache.org/jmeter/usermanual/component_reference.html#HTTP_Header_Manager
Post by Laurent Perez
at the HTTP Request level (instead of Thread group level).
So I guess you could create a header named Cookie for each request. If
cookies values need to be dynamic ones, you could use some post
processor to extract Set-cookie values from the response and store
them as variables.
Don't know if this would fit your needs, I never tried this.
laurent
Post by henryd
Sincerely appreciate your help.
--
http://www.nabble.com/Insert-Cookies-for-some-requests-in-a-thread-group-tp19709256p19709256.html
Post by Laurent Perez
Post by henryd
Sent from the JMeter - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
--
http://in-pocket.blogspot.com http://in-pocket.blogspot.com
- Mobile world, technology and more
---------------------------------------------------------------------
--
http://www.nabble.com/Insert-Cookies-for-some-requests-in-a-thread-group-tp19709256p19712078.html
Sent from the JMeter - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
---------------------------------------------------------------------
http://www.nabble.com/Insert-Cookies-for-some-requests-in-a-thread-group-tp19709256p19712903.html
henryd
2008-09-29 14:19:29 UTC
Permalink
It is still not working for me. I have a cookie manager at the thread group
level for all my 20 requests. I added a "cookie manager" as a child for one
request and added two cookies to it. These cookies are not being sent along
with my request. They get sent only if I disable the main "cookie manager"
at the thread group level. I am stuck as it appears like Jmeter does not
support adding a browser cookie for one or two requests in my thread group
while I have another cookie manager at the thread group level for server
cookies for the remaining 18 requests.
Post by sebb
Sorry, if I did not make myself clear. I am using "2.3.2.r665936". I am
not concerned about the cookies sent by server in this case. The
javascripts on my web pages set some cookies for certain requests
resulting in browser sending a request to the server with this new cookie
or a different value for the same cookie. This is where I am having real
problem. Is there any way to send a specific cookie for a couple of
requests in my thread group where I have 20 requests all together.
Yes, if you want to ignore server cookies, just add the cookie manager
as a child of each request that needs the specific cookies.
BTW, what happens when I set "automatic redirection" and the server sets
a new cookie and issues a 302 and the subsequent request goes to the
redirected url with this new cookie. Will this work in Jmeter or do I
need to create two different requests instead of setting "automatic
redirection".
http://jakarta.apache.org/jmeter/usermanual/component_reference.html#HTTP_Request
See "Redirect Automatically" and "Follow Redirects"
Post by sebb
No need to use multiple cookie managers - anyway, they won't work.
If the server sets a cookie, it will be seen by JMeter (unless you are
using redirect automatically), and JMeter will send any relevant
cookies with the next request.
If you want to add your own cookies, add them to the cookie manager.
But this is rarely needed.
Note that there was a problem in 2.3.1 if you selected "Clear cookies
each iteration".
Upgrade to 2.3.2 if necessary.
Post by henryd
I have tried adding "Cookie" as a header and jmeter does not treat
it as
Post by sebb
Post by henryd
cookie and that does not appear in the outgoing request. I wish I
could
Post by sebb
Post by henryd
use
additional "Cookie Managers" in addition to adding at thread level
to
Post by sebb
Post by henryd
add
extra cookies or change cookies to what I am getting by adding it at
the
Post by sebb
Post by henryd
thread level.
Post by Laurent Perez
Post by henryd
How can I add my own cookies for some requests. If I add it to
the
Post by sebb
Post by henryd
cookie
Post by Laurent Perez
Post by henryd
manager at the thread level, these cookies get added to all
requests.
Post by sebb
Post by henryd
Post by Laurent Perez
I believe you can use
http://jakarta.apache.org/jmeter/usermanual/component_reference.html#HTTP_Header_Manager
Post by sebb
Post by henryd
Post by Laurent Perez
at the HTTP Request level (instead of Thread group level).
So I guess you could create a header named Cookie for each
request. If
Post by sebb
Post by henryd
Post by Laurent Perez
cookies values need to be dynamic ones, you could use some post
processor to extract Set-cookie values from the response and store
them as variables.
Don't know if this would fit your needs, I never tried this.
laurent
Post by henryd
Sincerely appreciate your help.
--
http://www.nabble.com/Insert-Cookies-for-some-requests-in-a-thread-group-tp19709256p19709256.html
Post by sebb
Post by henryd
Post by Laurent Perez
Post by henryd
Sent from the JMeter - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
Post by sebb
Post by henryd
Post by Laurent Perez
--
http://in-pocket.blogspot.com http://in-pocket.blogspot.com
- Mobile world, technology and more
---------------------------------------------------------------------
Post by sebb
Post by henryd
--
http://www.nabble.com/Insert-Cookies-for-some-requests-in-a-thread-group-tp19709256p19712078.html
Post by sebb
Post by henryd
Sent from the JMeter - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
Post by sebb
---------------------------------------------------------------------
http://www.nabble.com/Insert-Cookies-for-some-requests-in-a-thread-group-tp19709256p19712903.html
---------------------------------------------------------------------
--
View this message in context: http://www.nabble.com/Insert-Cookies-for-some-requests-in-a-thread-group-tp19709256p19724807.html
Sent from the JMeter - User mailing list archive at Nabble.com.
sebb
2008-09-29 17:14:24 UTC
Permalink
Post by henryd
It is still not working for me. I have a cookie manager at the thread group
level for all my 20 requests. I added a "cookie manager" as a child for one
request and added two cookies to it. These cookies are not being sent along
with my request. They get sent only if I disable the main "cookie manager"
at the thread group level. I am stuck as it appears like Jmeter does not
support adding a browser cookie for one or two requests in my thread group
while I have another cookie manager at the thread group level for server
cookies for the remaining 18 requests.
Post by sebb
Yes, if you want to ignore server cookies, just add the cookie manager
as a child of each request that needs the specific cookies.
If a Sampler finds multiple Cookie Managers in the same scope, then
only one CM will be used - as you have found out.

However, you can use variables in the Cookie Manager.
So if the server does not mind getting extra cookies, you can define
the extra cookies that you need, and set the variables as needed.
Post by henryd
Post by sebb
Sorry, if I did not make myself clear. I am using "2.3.2.r665936". I am
not concerned about the cookies sent by server in this case. The
javascripts on my web pages set some cookies for certain requests
resulting in browser sending a request to the server with this new cookie
or a different value for the same cookie. This is where I am having real
problem. Is there any way to send a specific cookie for a couple of
requests in my thread group where I have 20 requests all together.
Yes, if you want to ignore server cookies, just add the cookie manager
as a child of each request that needs the specific cookies.
BTW, what happens when I set "automatic redirection" and the server sets
a new cookie and issues a 302 and the subsequent request goes to the
redirected url with this new cookie. Will this work in Jmeter or do I
need to create two different requests instead of setting "automatic
redirection".
http://jakarta.apache.org/jmeter/usermanual/component_reference.html#HTTP_Request
See "Redirect Automatically" and "Follow Redirects"
Post by sebb
No need to use multiple cookie managers - anyway, they won't work.
If the server sets a cookie, it will be seen by JMeter (unless you are
using redirect automatically), and JMeter will send any relevant
cookies with the next request.
If you want to add your own cookies, add them to the cookie manager.
But this is rarely needed.
Note that there was a problem in 2.3.1 if you selected "Clear cookies
each iteration".
Upgrade to 2.3.2 if necessary.
Post by henryd
I have tried adding "Cookie" as a header and jmeter does not treat
it as
Post by sebb
Post by henryd
cookie and that does not appear in the outgoing request. I wish I
could
Post by sebb
Post by henryd
use
additional "Cookie Managers" in addition to adding at thread level
to
Post by sebb
Post by henryd
add
extra cookies or change cookies to what I am getting by adding it at
the
Post by sebb
Post by henryd
thread level.
Post by Laurent Perez
Post by henryd
How can I add my own cookies for some requests. If I add it to
the
Post by sebb
Post by henryd
cookie
Post by Laurent Perez
Post by henryd
manager at the thread level, these cookies get added to all
requests.
Post by sebb
Post by henryd
Post by Laurent Perez
I believe you can use
http://jakarta.apache.org/jmeter/usermanual/component_reference.html#HTTP_Header_Manager
Post by sebb
Post by henryd
Post by Laurent Perez
at the HTTP Request level (instead of Thread group level).
So I guess you could create a header named Cookie for each
request. If
Post by sebb
Post by henryd
Post by Laurent Perez
cookies values need to be dynamic ones, you could use some post
processor to extract Set-cookie values from the response and store
them as variables.
Don't know if this would fit your needs, I never tried this.
laurent
Post by henryd
Sincerely appreciate your help.
--
http://www.nabble.com/Insert-Cookies-for-some-requests-in-a-thread-group-tp19709256p19709256.html
Post by sebb
Post by henryd
Post by Laurent Perez
Post by henryd
Sent from the JMeter - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
Post by sebb
Post by henryd
Post by Laurent Perez
--
http://in-pocket.blogspot.com http://in-pocket.blogspot.com
- Mobile world, technology and more
---------------------------------------------------------------------
Post by sebb
Post by henryd
--
http://www.nabble.com/Insert-Cookies-for-some-requests-in-a-thread-group-tp19709256p19712078.html
Post by sebb
Post by henryd
Sent from the JMeter - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
Post by sebb
---------------------------------------------------------------------
http://www.nabble.com/Insert-Cookies-for-some-requests-in-a-thread-group-tp19709256p19712903.html
---------------------------------------------------------------------
--
View this message in context: http://www.nabble.com/Insert-Cookies-for-some-requests-in-a-thread-group-tp19709256p19724807.html
Sent from the JMeter - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
henryd
2008-09-29 17:44:39 UTC
Permalink
I have two requests out of the 20 request that have a browser cookie. The
problem I am having is that the same cookie (eg: s_ec) needs to be sent with
different values for request #12 and request #18. If I add this cookie, I am
unable to change the value of the cookie.
Post by sebb
Post by henryd
It is still not working for me. I have a cookie manager at the thread group
level for all my 20 requests. I added a "cookie manager" as a child for one
request and added two cookies to it. These cookies are not being sent along
with my request. They get sent only if I disable the main "cookie manager"
at the thread group level. I am stuck as it appears like Jmeter does not
support adding a browser cookie for one or two requests in my thread group
while I have another cookie manager at the thread group level for server
cookies for the remaining 18 requests.
Post by sebb
Yes, if you want to ignore server cookies, just add the cookie manager
as a child of each request that needs the specific cookies.
If a Sampler finds multiple Cookie Managers in the same scope, then
only one CM will be used - as you have found out.
However, you can use variables in the Cookie Manager.
So if the server does not mind getting extra cookies, you can define
the extra cookies that you need, and set the variables as needed.
Post by henryd
Post by sebb
Sorry, if I did not make myself clear. I am using "2.3.2.r665936". I
am
Post by sebb
not concerned about the cookies sent by server in this case. The
javascripts on my web pages set some cookies for certain requests
resulting in browser sending a request to the server with this new
cookie
Post by sebb
or a different value for the same cookie. This is where I am having
real
Post by sebb
problem. Is there any way to send a specific cookie for a couple of
requests in my thread group where I have 20 requests all together.
Yes, if you want to ignore server cookies, just add the cookie manager
as a child of each request that needs the specific cookies.
BTW, what happens when I set "automatic redirection" and the server
sets
Post by sebb
a new cookie and issues a 302 and the subsequent request goes to the
redirected url with this new cookie. Will this work in Jmeter or do I
need to create two different requests instead of setting "automatic
redirection".
http://jakarta.apache.org/jmeter/usermanual/component_reference.html#HTTP_Request
Post by sebb
See "Redirect Automatically" and "Follow Redirects"
Post by sebb
No need to use multiple cookie managers - anyway, they won't work.
If the server sets a cookie, it will be seen by JMeter (unless you
are
Post by sebb
Post by sebb
using redirect automatically), and JMeter will send any relevant
cookies with the next request.
If you want to add your own cookies, add them to the cookie
manager.
Post by sebb
Post by sebb
But this is rarely needed.
Note that there was a problem in 2.3.1 if you selected "Clear
cookies
Post by sebb
Post by sebb
each iteration".
Upgrade to 2.3.2 if necessary.
Post by henryd
I have tried adding "Cookie" as a header and jmeter does not
treat
Post by sebb
it as
Post by sebb
Post by henryd
cookie and that does not appear in the outgoing request. I wish
I
Post by sebb
could
Post by sebb
Post by henryd
use
additional "Cookie Managers" in addition to adding at thread
level
Post by sebb
to
Post by sebb
Post by henryd
add
extra cookies or change cookies to what I am getting by adding
it at
Post by sebb
the
Post by sebb
Post by henryd
thread level.
Post by Laurent Perez
Post by henryd
How can I add my own cookies for some requests. If I add it
to
Post by sebb
the
Post by sebb
Post by henryd
cookie
Post by Laurent Perez
Post by henryd
manager at the thread level, these cookies get added to all
requests.
Post by sebb
Post by henryd
Post by Laurent Perez
I believe you can use
http://jakarta.apache.org/jmeter/usermanual/component_reference.html#HTTP_Header_Manager
Post by sebb
Post by sebb
Post by henryd
Post by Laurent Perez
at the HTTP Request level (instead of Thread group level).
So I guess you could create a header named Cookie for each
request. If
Post by sebb
Post by henryd
Post by Laurent Perez
cookies values need to be dynamic ones, you could use some
post
Post by sebb
Post by sebb
Post by henryd
Post by Laurent Perez
processor to extract Set-cookie values from the response and
store
Post by sebb
Post by sebb
Post by henryd
Post by Laurent Perez
them as variables.
Don't know if this would fit your needs, I never tried this.
laurent
Post by henryd
Sincerely appreciate your help.
--
http://www.nabble.com/Insert-Cookies-for-some-requests-in-a-thread-group-tp19709256p19709256.html
Post by sebb
Post by sebb
Post by henryd
Post by Laurent Perez
Post by henryd
Sent from the JMeter - User mailing list archive at
Nabble.com.
Post by sebb
---------------------------------------------------------------------
Post by sebb
Post by henryd
Post by Laurent Perez
--
http://in-pocket.blogspot.com http://in-pocket.blogspot.com
- Mobile world, technology and more
---------------------------------------------------------------------
Post by sebb
Post by henryd
--
http://www.nabble.com/Insert-Cookies-for-some-requests-in-a-thread-group-tp19709256p19712078.html
Post by sebb
Post by sebb
Post by henryd
Sent from the JMeter - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
---------------------------------------------------------------------
http://www.nabble.com/Insert-Cookies-for-some-requests-in-a-thread-group-tp19709256p19712903.html
Post by sebb
---------------------------------------------------------------------
--
http://www.nabble.com/Insert-Cookies-for-some-requests-in-a-thread-group-tp19709256p19724807.html
Sent from the JMeter - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
---------------------------------------------------------------------
--
View this message in context: http://www.nabble.com/Insert-Cookies-for-some-requests-in-a-thread-group-tp19709256p19728474.html
Sent from the JMeter - User mailing list archive at Nabble.com.
sebb
2008-09-29 17:56:51 UTC
Permalink
Post by henryd
Post by sebb
However, you can use variables in the Cookie Manager.
So if the server does not mind getting extra cookies, you can define
the extra cookies that you need, and set the variables as needed.
So add a cookie which looks like:

Name: s_ec
Value: ${xyx}

and define xyz to be whatever you want.
Post by henryd
I have two requests out of the 20 request that have a browser cookie. The
problem I am having is that the same cookie (eg: s_ec) needs to be sent with
different values for request #12 and request #18. If I add this cookie, I am
unable to change the value of the cookie.
Post by sebb
Post by henryd
It is still not working for me. I have a cookie manager at the thread group
level for all my 20 requests. I added a "cookie manager" as a child for one
request and added two cookies to it. These cookies are not being sent along
with my request. They get sent only if I disable the main "cookie manager"
at the thread group level. I am stuck as it appears like Jmeter does not
support adding a browser cookie for one or two requests in my thread group
while I have another cookie manager at the thread group level for server
cookies for the remaining 18 requests.
Post by sebb
Yes, if you want to ignore server cookies, just add the cookie manager
as a child of each request that needs the specific cookies.
If a Sampler finds multiple Cookie Managers in the same scope, then
only one CM will be used - as you have found out.
However, you can use variables in the Cookie Manager.
So if the server does not mind getting extra cookies, you can define
the extra cookies that you need, and set the variables as needed.
Post by henryd
Post by sebb
Sorry, if I did not make myself clear. I am using "2.3.2.r665936". I
am
Post by sebb
not concerned about the cookies sent by server in this case. The
javascripts on my web pages set some cookies for certain requests
resulting in browser sending a request to the server with this new
cookie
Post by sebb
or a different value for the same cookie. This is where I am having
real
Post by sebb
problem. Is there any way to send a specific cookie for a couple of
requests in my thread group where I have 20 requests all together.
Yes, if you want to ignore server cookies, just add the cookie manager
as a child of each request that needs the specific cookies.
BTW, what happens when I set "automatic redirection" and the server
sets
Post by sebb
a new cookie and issues a 302 and the subsequent request goes to the
redirected url with this new cookie. Will this work in Jmeter or do I
need to create two different requests instead of setting "automatic
redirection".
http://jakarta.apache.org/jmeter/usermanual/component_reference.html#HTTP_Request
Post by sebb
See "Redirect Automatically" and "Follow Redirects"
Post by sebb
No need to use multiple cookie managers - anyway, they won't work.
If the server sets a cookie, it will be seen by JMeter (unless you
are
Post by sebb
Post by sebb
using redirect automatically), and JMeter will send any relevant
cookies with the next request.
If you want to add your own cookies, add them to the cookie
manager.
Post by sebb
Post by sebb
But this is rarely needed.
Note that there was a problem in 2.3.1 if you selected "Clear
cookies
Post by sebb
Post by sebb
each iteration".
Upgrade to 2.3.2 if necessary.
Post by henryd
I have tried adding "Cookie" as a header and jmeter does not
treat
Post by sebb
it as
Post by sebb
Post by henryd
cookie and that does not appear in the outgoing request. I wish
I
Post by sebb
could
Post by sebb
Post by henryd
use
additional "Cookie Managers" in addition to adding at thread
level
Post by sebb
to
Post by sebb
Post by henryd
add
extra cookies or change cookies to what I am getting by adding
it at
Post by sebb
the
Post by sebb
Post by henryd
thread level.
Post by Laurent Perez
Post by henryd
How can I add my own cookies for some requests. If I add it
to
Post by sebb
the
Post by sebb
Post by henryd
cookie
Post by Laurent Perez
Post by henryd
manager at the thread level, these cookies get added to all
requests.
Post by sebb
Post by henryd
Post by Laurent Perez
I believe you can use
http://jakarta.apache.org/jmeter/usermanual/component_reference.html#HTTP_Header_Manager
Post by sebb
Post by sebb
Post by henryd
Post by Laurent Perez
at the HTTP Request level (instead of Thread group level).
So I guess you could create a header named Cookie for each
request. If
Post by sebb
Post by henryd
Post by Laurent Perez
cookies values need to be dynamic ones, you could use some
post
Post by sebb
Post by sebb
Post by henryd
Post by Laurent Perez
processor to extract Set-cookie values from the response and
store
Post by sebb
Post by sebb
Post by henryd
Post by Laurent Perez
them as variables.
Don't know if this would fit your needs, I never tried this.
laurent
Post by henryd
Sincerely appreciate your help.
--
henryd
2008-09-30 15:14:41 UTC
Permalink
How do I dynamically change the value of the variable before a specific
request.

I need to send this for request#12:
"Cookie: s_cc=true; s_sq=%5B%5BB%5D%5D; "

and

I need to send this for for request#18:
"Cookie: s_cc=true;
s_sq=aolregistrationdev%3D%2526pid%253Dreg%252520%25253A%252520Free%252520AOL%252520Registration%252520G2%2526pidt%253D1%2526oid%253DSubmit%2526oidt%253D3%2526ot%253DSUBMIT%2526oi%253D219"
Post by sebb
Post by henryd
Post by sebb
However, you can use variables in the Cookie Manager.
So if the server does not mind getting extra cookies, you can define
the extra cookies that you need, and set the variables as needed.
Name: s_ec
Value: ${xyx}
and define xyz to be whatever you want.
Post by henryd
I have two requests out of the 20 request that have a browser cookie. The
problem I am having is that the same cookie (eg: s_ec) needs to be sent with
different values for request #12 and request #18. If I add this cookie, I am
unable to change the value of the cookie.
Post by sebb
Post by henryd
It is still not working for me. I have a cookie manager at the
thread
Post by sebb
Post by henryd
group
level for all my 20 requests. I added a "cookie manager" as a child
for
Post by sebb
Post by henryd
one
request and added two cookies to it. These cookies are not being
sent
Post by sebb
Post by henryd
along
with my request. They get sent only if I disable the main "cookie manager"
at the thread group level. I am stuck as it appears like Jmeter does
not
Post by sebb
Post by henryd
support adding a browser cookie for one or two requests in my thread group
while I have another cookie manager at the thread group level for
server
Post by sebb
Post by henryd
cookies for the remaining 18 requests.
You wrote that you were not interested in server cookies, which is why
I
Post by sebb
Post by henryd
Post by sebb
Yes, if you want to ignore server cookies, just add the cookie
manager
Post by sebb
Post by henryd
Post by sebb
as a child of each request that needs the specific cookies.
If a Sampler finds multiple Cookie Managers in the same scope, then
only one CM will be used - as you have found out.
However, you can use variables in the Cookie Manager.
So if the server does not mind getting extra cookies, you can define
the extra cookies that you need, and set the variables as needed.
Post by henryd
Post by sebb
Sorry, if I did not make myself clear. I am using
"2.3.2.r665936". I
Post by sebb
Post by henryd
am
Post by sebb
not concerned about the cookies sent by server in this case. The
javascripts on my web pages set some cookies for certain requests
resulting in browser sending a request to the server with this
new
Post by sebb
Post by henryd
cookie
Post by sebb
or a different value for the same cookie. This is where I am
having
Post by sebb
Post by henryd
real
Post by sebb
problem. Is there any way to send a specific cookie for a couple
of
Post by sebb
Post by henryd
Post by sebb
requests in my thread group where I have 20 requests all
together.
Post by sebb
Post by henryd
Post by sebb
Yes, if you want to ignore server cookies, just add the cookie
manager
Post by sebb
Post by henryd
Post by sebb
as a child of each request that needs the specific cookies.
BTW, what happens when I set "automatic redirection" and the
server
Post by sebb
Post by henryd
sets
Post by sebb
a new cookie and issues a 302 and the subsequent request goes to
the
Post by sebb
Post by henryd
Post by sebb
redirected url with this new cookie. Will this work in Jmeter or
do I
Post by sebb
Post by henryd
Post by sebb
need to create two different requests instead of setting
"automatic
Post by sebb
Post by henryd
Post by sebb
redirection".
http://jakarta.apache.org/jmeter/usermanual/component_reference.html#HTTP_Request
Post by sebb
Post by henryd
Post by sebb
See "Redirect Automatically" and "Follow Redirects"
Post by sebb
No need to use multiple cookie managers - anyway, they won't
work.
Post by sebb
Post by henryd
Post by sebb
Post by sebb
If the server sets a cookie, it will be seen by JMeter (unless
you
Post by sebb
Post by henryd
are
Post by sebb
Post by sebb
using redirect automatically), and JMeter will send any
relevant
Post by sebb
Post by henryd
Post by sebb
Post by sebb
cookies with the next request.
If you want to add your own cookies, add them to the cookie
manager.
Post by sebb
Post by sebb
But this is rarely needed.
Note that there was a problem in 2.3.1 if you selected "Clear
cookies
Post by sebb
Post by sebb
each iteration".
Upgrade to 2.3.2 if necessary.
Post by henryd
I have tried adding "Cookie" as a header and jmeter does not
treat
Post by sebb
it as
Post by sebb
Post by henryd
cookie and that does not appear in the outgoing request. I
wish
Post by sebb
Post by henryd
I
Post by sebb
could
Post by sebb
Post by henryd
use
additional "Cookie Managers" in addition to adding at
thread
Post by sebb
Post by henryd
level
Post by sebb
to
Post by sebb
Post by henryd
add
extra cookies or change cookies to what I am getting by
adding
Post by sebb
Post by henryd
it at
Post by sebb
the
Post by sebb
Post by henryd
thread level.
Post by Laurent Perez
Post by henryd
How can I add my own cookies for some requests. If I add
it
Post by sebb
Post by henryd
to
Post by sebb
the
Post by sebb
Post by henryd
cookie
Post by Laurent Perez
Post by henryd
manager at the thread level, these cookies get added to
all
Post by sebb
Post by henryd
Post by sebb
requests.
Post by sebb
Post by henryd
Post by Laurent Perez
I believe you can use
http://jakarta.apache.org/jmeter/usermanual/component_reference.html#HTTP_Header_Manager
Post by sebb
Post by henryd
Post by sebb
Post by sebb
Post by henryd
Post by Laurent Perez
at the HTTP Request level (instead of Thread group level).
So I guess you could create a header named Cookie for each
request. If
Post by sebb
Post by henryd
Post by Laurent Perez
cookies values need to be dynamic ones, you could use some
post
Post by sebb
Post by sebb
Post by henryd
Post by Laurent Perez
processor to extract Set-cookie values from the response
and
Post by sebb
Post by henryd
store
Post by sebb
Post by sebb
Post by henryd
Post by Laurent Perez
them as variables.
Don't know if this would fit your needs, I never tried
this.
Post by sebb
Post by henryd
Post by sebb
Post by sebb
Post by henryd
Post by Laurent Perez
laurent
Post by henryd
Sincerely appreciate your help.
--
---------------------------------------------------------------------
--
View this message in context: http://www.nabble.com/Insert-Cookies-for-some-requests-in-a-thread-group-tp19709256p19744133.html
Sent from the JMeter - User mailing list archive at Nabble.com.
Continue reading on narkive:
Loading...