Re: Who is logged in?
Steve,
many thanks for the last suggestion. I moved the code up and it works as expected.
Andy Sigrist
Steve,
many thanks for the last suggestion. I moved the code up and it works as expected.
Andy Sigrist
Alpha Software Mobile Development Tools: Alpha Anywhere | Alpha TransForm |
x_login = a5w_run_Component(tmpl_login) '============================================================================================================= if x_login.RedirectURL <> "" then
response.redirect(x_login.redirectURL) end end if
if x_login.RedirectURL <> "" then dim pUser as p a5ws_Logged_In_User_Values(pUser) if pUser.Userid <> "" ' should always be true after a successful login tbl = table.open("[PathAlias.ADB_Path]\Web_Log.dbf") tbl.enter_begin() tbl.Userlogin = pUser.Userid tbl.Logindate = Date() tbl.logintime = Time() tbl.enter_end() tbl.close() end if response.redirect(x_login.redirectURL) end end if
function saveLoginLog as v (e as p) '-- Values Available - Data type - Description 'e.session - Pointer - session variables. TIP: To set a session variable: e.Session.myNewSessionVariable = "Alpha" 'e.userid - Character - userid of the logged in user 'e.ulink - Character - 'ulink' value saved for the logged in user 'e.passexp - Time - a time value indicating when the user's password will expire 'e.loginexp - Time - a time value indicating when the login will expire 'e.loginerror - Character - any error message returned from a login component if a login failed 'e.IP - Character - IP address of the remote client making the request 'e.logout - Logical - Default is .F., will be .T. if the action is a 'log out' ''=============================================================================== Dim conn as SQL::connection Dim args as SQL::Arguments Dim SQL as c vHost = request.host vNow = now() If e.logout = .T. vType = "LogOut" vExpires = vNow Else vType = "LogIn" vExpires = vNow + (session.timeout*60) End If args.add("LoginName",e.userid) args.add("DateTime",vNow) args.add("Type",vType) args.add("IP",e.IP) args.add("LogExpires",vExpires) args.add("PwdExpires",e.passexp) args.add("LogError",e.loginerror) args.add("Host",vHost) SQL = "INSERT INTO Login_Activity (LogLoginName, LogDateTime, LogType, LogIP, LogExpires, LogPwdExpires, LogError, LogHost) VALUES (:LoginName, :DateTime, :Type, :IP, :LogExpires, :PwdExpires, :LogError, :Host)" conn.open("::Name::System") conn.execute(SQL, args) conn.close() end function
<%a5 dim args as SQL::Arguments args.set("ulink",session.__protected__ulink) dim email_logged_in as C=convert_type(sql_lookup("::name::conn","websecurity_users","ulink=:ulink","userid",args),"C") ?"You are logged in as: "+email_logged_in %>
Comment