PageReceived Return to same WebSession and Process JSON

I simply cannot figure this out. How to get PageRecieved to return the JSON into the calling Session Window.

I have a Login WebView, Button “Login” that fires a HTTP request. Once the PageRecieved it activated I need to process if LoginDetails = OK, and then open a new WebWindow (UserLocations) instead of the LoginWindow.

How to do that? I keep getting SessionNotAvaiableException, but I can’t figure out how to…

Should I pack the Session ID into both Sending and Receiving JSON? - But then how to Open the new Window in the same Session?

What is it firing a HTTP request to? Another site?

It’s sending it to a Xojo Web Service. My Client is sending, fine, Middleware is receiving and sending fine, but once I receive the returned JSON I need to ‘Reactivate’ the Session that called it and…

Dim w as New CheckInWindow
w.Initialize
// Send the new window som parameters so I use my own Show method

I can’t open the new Windows as I get a SessionNotAvaiableException

You can’t reactivate sessions once they are closed, it would create a security issue it you could.

Call your authentication service and return some kind of time limited token, then pass that to your website to create a new session.

The Session is never closed. Here’s the process

Show Login Window [WORKS]
Press Login [WORKS]
Send Login Details via HTTPSocket [WORKS]
Receive LoginIsOK via PageRecieved [WORKS]
Show UserLocationsWindow in stead of LoginWindow [DOES NOT WORK]

This must be possible, right? Any ideas. I have a feeling it’s quite simple, but I’m not that experienced in HTTPSockets and Web Services

Create a socket subclass (UrlConnection) name it MySocket for example in the constructor add parameter Sess As Session

Set that inside the constructor to a private property in the subclass.

Inside the pagereceived event you should be able to reference the given session using Sess.* and set properties etc

In a webpage you can add the subclassed socket now from code:
Var/Dim mysock As New MySocket(Session)
Mysock.Send( blah blah )

Something like that could work.
Or use WebSessionContext to get the reference another way.
https://documentation.xojo.com/api/web/websession.htmlContext