B4J Question [ABMaterial] How or where to check if new session

Cableguy

Expert
Licensed User
Longtime User
Hi ABM gurus

I am trying to figure out how or where can I check if the page session is a new one?
I am trying to change the visibility of a few rows depending on User status (Logged in or not) and session status (New session or existing one)

My logic would be:

I will have 2 TopBanner Rows, one with 2 buttons (REGISTER and LOGIN) and another with User Info.
If UserIsGuest = true or SessionIsNew = true then show Topbar1, Hide TopBar2
If UserIsGuest = false and PageComesFromCache = True then Show TopBar1, Hide ToBar2
If UserIsGuest = false (logged in) and SessionIsNew = True then show TopBar1, Hide TopBar2
If UserIsGuest = false and SessionIsNew = False then Hide TopBar1, Show TopBar2

Problem is, is my logic accurate? where can I check all that?
 

mindful

Active Member
Licensed User
B4X:
ws.Session.IsNew
returns if the session was created in that request (it means that the user accessed the page directly (eg. http://your-url/yourapp/loginpage) and the app created the session)

Of what I can undersand you have to containers one with a from for register or login which should be shown if the user isn't logged in and another one displaying some info for the logged user.

if that is the case you should setup a session attribute the you check something like "LoggedInUserId" so if that attribute returns a value then it means that the user has a session which was created in the past and also has logged in so when checking that attribute if it returns a valid value then you show topbar2 otherwise you show topbar1.
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
ws.session.isnew throws an exception when used in page_uild, so I guess I need to use it on page_connect (?)
 
Upvote 0
Top