Thanks Stephane! After implementing your suggestion, I noticed that the check is happening, but the status code is not getting saved in the session attribute. I am getting this error in the log file:
00:58:58.179 [ERROR] i.g.c.a.b.SessionHookBuilder$$anon$1 - 'hook-3' crashed with 'j.u.NoSuchElementException: No attribute named 'STATUS_CODE' is defined', forwarding to the next one
Is this happening because Gatling moves to the next request as soon as the check fails? Here is my check expression : check(responseTimeInMillis.saveAs("PREV_REQ_RESP_TIME"), status.is(200).saveAs("STATUS_CODE"))