Escape `_` in LIKE to allow index search

Also filters for expired sessions in DB, not PHP.
Fixes #6916