Keep the query string and path in store_location_for

Persist the URI's query when saving to the session.

Fixes #2742