util: fix issue with bad sessionId on H2

If a garbage JSESSIONID cookie was set, H2 would throw an exception
at runtime when building the query.

Add some sanity checks before passing the sessionId to the DAO.

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>