OK, I think I understand.
You want the user to click a button, and have it log in to a site to get the session id, and then open a new page but carry that session id with it. In the end you want a seperate window with that session in the query string.
Here are the steps I would take. You'll have to modify them to fit your needs.
Visitor clicks link to open page in new window (or submits form, or whatever). That page then creates the session. If you want to get the session id from the url, then just access it with $_server['query_string']. Then do a meta refresh or a header("Location:...") to the location you ultimately want them at, and just stick the session id in their.