Function called from WebSession.Close() doesn't have Session object

MacOS, Xojo 2019R1.1

in a function, called from WebSession.Close() it doesn’t have access to the “Session” object. It’s NIL.

Is there a way to access “Session” object when called from WebSession.Close()?

Thanks

To refer to the current Session from within the Session object, use Self instead of Session as the prefix, especially in the Opening event because it may return Nil.

Source:
https://documentation.xojo.com/api/web/session.html

1 Like

Thanks, but the function called from WebSession.close() is from a Module. I think “SELF” will not work there

So either restructure or check to be sure Session isn’t nil before using it.

If you’re going to need to access something about the Session then you’ll need to go with the restructure route.

Are you passing the Session object from Close to your method? Is Session nil in the Close event?

I’ve run into the same problem. The use case is: If the user starts to fill out a web form, and then they just quit the browser, we’d like to capture the data that’s in there.

So what would be useful to do is on session close, write that information to the database. Unfortunately you run into the session information being destroyed before you can save it