B4J Question [ABMaterial] username

codie01

Active Member
Licensed User
Longtime User
I have a logon page. I need to store the username local to the user. How and where do I store this. Thanks!
 

Harris

Expert
Licensed User
Longtime User
Create session vars (cookies).
If you use a table for users, lookup username and password.

Then, on each page, retreive the user name:
currentuser = ws.Session.GetAttribute2("Username", "")



B4X:
    Dim users As List = DBM.SQLSelect(SQL, "SELECT * FROM users WHERE UserLogin='" & logininp1.text & "' AND UserPassword='" & logininp2.Text & "'")
                If users.Size > 0 Then   
                    Dim user As Map = users.Get(0)
                    Page.ws.Session.SetAttribute("authType", "local")
                    Page.ws.Session.SetAttribute("authName", logininp1)
                    Page.ws.Session.SetAttribute("IsAuthorized", "true")
                    Page.ws.Session.SetAttribute("UserType", "" & user.Get("usertype") )    ' lowercase!               
                    Page.ws.Session.SetAttribute("UserID", "" & user.Get("userid") ) ' lowercase!
                    Page.ws.Session.SetAttribute("UserRows",  user.Get("userrows") ) ' lowercase!
                    Page.ws.Session.SetAttribute("Username",  user.Get("userlogin") ) ' lowercase!
                  else
                       log("user not found")
                  end if
 
Upvote 0
Top