refactor search history logic so we're pulling search query parameters o...

...ut of the database, not the session.