Query with values (URGENT)

I have a collection with three different doctypes,
Firstly I have a logging page if the user goes through I pass parameter to the next page with that same paramether I query the database that if the user exist then query the next doctype with the value I’m coming with. I’m trying to create a session roughly.

SomeHelp ?

I don’t need predefined joins I want my jopins to be dynamic.

This goes with the topic above