B4J Question [ABMaterial]: [Solved] How to view session storage?

Mashiane

Expert
Licensed User
Longtime User
Hi there

I'm trying to view what has been stored in my session storage using F12 (developer console), dololo. For some reason I'm saving stuff and it does not seem to register them in the sessions or even read them. I'm sure I'm doing something somewhere?

Can someone please advise?

Thanks a lot in advance for your help.
 

Mashiane

Expert
Licensed User
Longtime User
Actually its like you cant, which is fine. Anyway I found my issue, the method to write to the session variable was Case Sensitive whilst my method to read the variables was lower-case. Everything is working as expected after fixing that. I have updated anything on my app that reads, removes and saves to the session with these ABMShared methods.

B4X:
Sub SessionStorageSave(page As ABMPage, key As String, value As Object)
    key = key.tolowercase
    page.ws.Session.SetAttribute(key, value)
End Sub
Sub SessionStorageRead(page As ABMPage, key As String) As Object
    key = key.tolowercase
    Return page.ws.Session.GetAttribute2(key, "")
End Sub
Sub SessionStorageRemove(page As ABMPage, key As String)
    key = key.tolowercase
    page.ws.Session.RemoveAttribute(key)
End Sub
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
my session storage using F12
FYI, session storage is server side. All you get on the browser side is a session id that the server uses to identify your browser's server storage. Out of the box, Jetty stores this information in memory and the sessions will be lost if Jetty restarts (for whatever reason).

If you want to view all the stored information for a browser's session id, use the GetAttributeNames method to get all the key names and use them with GetAttribute to get the values for the keys. This would have to be done on the server side. Please note that this will only get you the session information for the browser session that you are using to retrieve the session information.
 
Upvote 0

Mashiane

Expert
Licensed User
Longtime User
FYI, session storage is server side. All you get on the browser side is a session id that the server uses to identify your browser's server storage. Out of the box, Jetty stores this information in memory and the sessions will be lost if Jetty restarts (for whatever reason).

If you want to view all the stored information for a browser's session id, use the GetAttributeNames method to get all the key names and use them with GetAttribute to get the values for the keys. This would have to be done on the server side. Please note that this will only get you the session information for the browser session that you are using to retrieve the session information.
Perfect explanation and clarity @OliverA, let me mark this as solved.
 
Upvote 0
Top