Login using curl:
curl -sw '%{http_code}' -o /dev/null -X POST -F "luci_username=root" -F "luci_password=root" http://192.168.1.1/cgi-bin/luci
The result will be 403
if the password is incorrect, or 302
in case of success
The session cookie looks like:
Set-Cookie: sysauth=xxxxxxxxxxxxxxxxxxxxxxxxxxxx; path=/cgi-bin/luci/; SameSite=Strict; HttpOnly