Sharing Session Across Tabs

Hi,

I have a WebPage that which has embedded a bunch of WebContainers that act as cells. In these cells, there are TextFields. The TextFields’ values are stored into an array property that is stored in the Session. If the user refreshes the page or opens a new tab, a new Session is created and therefore the array of the TextField’s values are lost. How can I maintain a shared Session property across tabs/windows? I know this will involve saving the Session Identifier in a Cookie and then comparing the Session, but I don’t know how to restore the root session.

Thanks in advance

You can’t re-create a session, but you could certainly store that data somewhere where all sessions can access, whether that’s off the App object maybe as an array stuffed into a dictionary with the known key or via a connection to a database from each session.

So where would I save this dictionary, Ian Jones? I’m very new to Xojo.

I typically create a ParentSession class and every time the user opens a new session in a new tab, I check for an existing parent session and relate them if there is a one or create a new Parent session. You’ll want to match not only on IP Address but also some cookie information. This ensures multiple people coming out of the same network can’t steal sessions. I also typically verify a few other credentials such as their browser version. Watch for circular references regarding session and remember to clean up parentSessions once all their child sessions have been closed.

Sorry I haven’t responded soon Eli, waaaaaay busy today! Looks like @Brock Nash has you covered, I’d only add (to answer your question to me) that you’d typically save the property on the App object and reference it from there.