Modern web logins rarely pass only a username and password. A JMeter test plan also has to carry the hidden form token, server-issued cookie, and protected follow-up request in the same virtual user session so the load test exercises the authenticated path instead of replaying a stale capture.
Correlation in JMeter pairs post-processors with the sampler that receives the dynamic value. The HTTP Cookie Manager stores server-set cookies per thread, while a CSS Selector Extractor or Regular Expression Extractor captures the form token that must be submitted by the next request.
Build the flow with one user and one loop before increasing thread count. A visible default such as TOKEN_NOT_FOUND makes extractor misses easy to spot, and the protected request should return an authorized response only after both the token and cookie are present.
Number of Threads (users): 1 Loop Count: 1
Keep the validation run small until the token, cookie, and protected request all pass for one virtual user.
Leave Clear Cookies each Iteration disabled when the later samplers in the same loop should remain logged in.
Related: How to add a Cookie Manager in JMeter
Name: GET /login Method: GET Path: /login
Name: Extract login CSRF token Name of created variable: csrf_token CSS/JQuery expression: form#login input[name=csrf] Attribute: value Match No.: 1 Default Value: TOKEN_NOT_FOUND
Use a Regular Expression Extractor only when the login response cannot be parsed with an HTML selector.
Related: How to extract HTML values with a CSS Selector Extractor in JMeter
Related: How to extract values with a regular expression in JMeter
Name: POST /login
Method: POST
Path: /login
Parameter: username = qa-user
Parameter: password = ${password}
Parameter: csrf = ${csrf_token}
Do not save live passwords, bearer tokens, or session cookies as literal values in a shared .jmx file. Load them from a variable source, test data file, or command-line property.
Name: GET /account Method: GET Path: /account
Do not add a manual Cookie header for the session. The HTTP Cookie Manager sends the server-issued cookie when the domain and path match.
login-session-correlate.jmx
$ jmeter -n -t login-session-correlate.jmx -l login-session-results.jtl Creating summariser <summary> Created the tree successfully using login-session-correlate.jmx Starting standalone test @ 2026 Jun 30 06:52:47 GMT Waiting for possible Shutdown/StopTestNow/HeapDump/ThreadDump message on port 4445 summary = 3 in 00:00:00 = 23.4/s Avg: 7 Min: 1 Max: 20 Err: 0 (0.00%) Tidying up ... ... end of run
$ cat login-session-results.jtl timeStamp,elapsed,label,responseCode,responseMessage,threadName,dataType,success,failureMessage,bytes,sentBytes,grpThreads,allThreads,URL,Latency,IdleTime,Connect 1782802367836,20,GET /login,200,OK,Login correlation user 1-1,text,true,,256,123,1,1,http://127.0.0.1:18083/login,16,0,13 1782802367890,2,POST /login,200,OK,Login correlation user 1-1,text,true,,155,280,1,1,http://127.0.0.1:18083/login,2,0,2 1782802367893,1,GET /account,200,OK,Login correlation user 1-1,text,true,,99,160,1,1,http://127.0.0.1:18083/account,1,0,1
The success column should show true for every sampler in the login path.
$ cat login-session-server.log server=listening port=18083 request method=GET path=/login cookie=- csrf=- status=200 request method=POST path=/login cookie=- csrf=csrf-abc-123 status=200 request method=GET path=/account cookie=SESSIONID=session-abc-123 csrf=- status=200
The POST line should show the extracted csrf value, and the protected request should show the session cookie from the login response. If the token is TOKEN_NOT_FOUND or the cookie is missing, inspect the extractor output before increasing thread count.
Related: How to add a Debug Sampler in JMeter