jmeterjmeter-5.0

How to maintain session?


I am using JMeter 5.6.3, trying to maintain a session on a legacy CodeIgniter 3.1.13 application in order to do load testing.

I have set up the test in this structure:

Test Plan: Login -> Dashboard -> Service Requests Listing
│
└── Thread Group (1 user, ramp-up 1s, loop 1x)
    │
    ├── HTTP Cookie Manager
    │
    ├── GET Login page
    │   ├── Header Manager
    │   ├── Constant Timer (3s)
    │   └── Regex Extractor (ci_session)
    │
    ├── POST Login page
    │   ├── Header Manager (includes dynamic Cookie header using ${cookie_session})
    │   └── Constant Timer (5s)
    │
    ├── GET Dashboard page
    │   ├── Header Manager
    │   ├── Constant Timer (15s)
    │   └── Response Assertion ("Task View")
    │
    ├── GET Open Service Requests page
    │   ├── Header Manager
    │   ├── Constant Timer (10s)
    │   └── Response Assertion ("Create Call Log")
    │
    ├── View Results Tree (Listener)
    └── Assertion Results (Listener)

The login does not succeed. It just keeps going back to the login page every time (our dashboard will redirect to login if authentication fails). I confirmed the login details are correct, yet login fails. Using the same login details with a browser login succeeds. I entered the credentials as follows on Post Body:

login=bliksempie@test.com
password=MyPasswordHereYes!
submit=Login

The form markup is like this for the login form (cleaned out extra markup for brevity), submitting to the controller that invoked the form:

<form action="/path/to/login" id="login-form" method="post" accept-charset="utf-8">
    <label for="login">Email Address</label>
    <input type="text" name="login" value="" id="login">
    <label for="password">Password</label>                    
    <input type="password" name="password" value="" id="password">
    <input type="submit" value="Login">
</form>

If the above information is sufficient, please can you advise if there is something obvious that I am missing please? If insufficient, please let me know what else you need to assess? I can provide the full JMeter test plan file if needed, as well as more debug panel logs.

I have checked this question which is similar in some ways: Jmeter unable to receive a new cookie and that does not work for me. Still not successful.

Here are some log data for reference if that means something to you:

2025-07-08 13:29:50,814 DEBUG o.a.j.p.h.c.HC4CookieHandler: Found 0 cookies for https://my.domain.com/appjourney/auth/login/
2025-07-08 13:29:50,889 DEBUG o.a.j.p.h.c.HC4CookieHandler: Received Cookie: ci_session=j0ognq498kl21s66mcsljkn482ov39ms; expires=Tue, 08 Jul 2025 21:29:50 GMT; Max-Age=36000; path=/; HttpOnly From: https://my.domain.com/appjourney/auth/login/
2025-07-08 13:29:50,889 DEBUG o.a.j.p.h.c.CookieManager: Add cookie to store my.domain.com  TRUE    /   FALSE   1752010190  ci_session  j0ognq498kl21s66mcsljkn482ov39ms
2025-07-08 13:29:55,891 DEBUG o.a.j.p.h.c.HC4CookieHandler: Found 1 cookies for https://my.domain.com/login
2025-07-08 13:30:10,955 DEBUG o.a.j.p.h.c.HC4CookieHandler: Found 1 cookies for https://my.domain.com/dashboard
2025-07-08 13:30:11,007 DEBUG o.a.j.p.h.s.HTTPSamplerBase: Location set to - https://my.domain.com/login/
2025-07-08 13:30:11,007 DEBUG o.a.j.p.h.s.HTTPSamplerBase: Initial location: https://my.domain.com/login/
2025-07-08 13:30:11,007 DEBUG o.a.j.p.h.s.HTTPSamplerBase: Location after /. and space transforms: https://my.domain.com/login/
2025-07-08 13:30:11,007 DEBUG o.a.j.p.h.s.HTTPSamplerBase: Location as URL: https://my.domain.com/login/
2025-07-08 13:30:11,007 DEBUG o.a.j.p.h.c.HC4CookieHandler: Found 1 cookies for https://my.domain.com/login/
2025-07-08 13:30:21,049 DEBUG o.a.j.p.h.c.HC4CookieHandler: Found 1 cookies for https://my.domain.com/dashboard/call_log/service/open/
2025-07-08 13:30:21,096 DEBUG o.a.j.p.h.s.HTTPSamplerBase: Location set to - https://my.domain.com/dashboard/login/
2025-07-08 13:30:21,096 DEBUG o.a.j.p.h.s.HTTPSamplerBase: Initial location: https://my.domain.com/dashboard/login/
2025-07-08 13:30:21,096 DEBUG o.a.j.p.h.s.HTTPSamplerBase: Location after /. and space transforms: https://my.domain.com/dashboard/login/
2025-07-08 13:30:21,096 DEBUG o.a.j.p.h.s.HTTPSamplerBase: Location as URL: https://my.domain.com/dashboard/login/
2025-07-08 13:30:21,096 DEBUG o.a.j.p.h.c.HC4CookieHandler: Found 1 cookies for https://my.domain.com/dashboard/login/

Any help will be greatly appreciated!


Solution

  • Please remove the Regular Expression Extractor and the Header Manager, you don't need to extract cookie value JMeter will do it automatically. There could also be other cookies

    Also take a closer look at parameters and headers sent by the real browser, it might be the case you will need to handle the CSRF token as well.

    And last but not the least be aware of Correlation Recorder Plugin which provides easier way of handling dynamic parameters and capable of automatically detecting them and generating suitable Regular Expression Extractors