This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Save the last login in object
#1
Hi, 

I want to display the date/time of the user when of his  last logged into  the LM5,

For example, I've 5 users

User 1 : date/time (virtual object)
User 2 : date/time (virtual object)
....

So, I want a script that could write the date/time in a virtual object of each user.

Is it possible?
Thanks in advance
Reply
#2
Create a scheduled script that runs as often as you want this data to be updated. Object type should be 250 byte string. Users are referenced by their login.

Code:
items = db:getall([[
  SELECT login, MAX(created) accessed
  FROM user_logs
  WHERE failed IS NULL or failed=0
  GROUP BY login
]])

logs = {}

for _, item in ipairs(items) do
  logs[ item.login ] = os.date('%c', item.accessed)
end

grp.checkupdate('1/1/1', logs.admin)
grp.checkupdate('1/1/2', logs.some_other_user)
grp.checkupdate('1/1/3', logs.another_user)
Reply
#3
(29.04.2022, 11:15)admin Wrote: Create a scheduled script that runs as often as you want this data to be updated. Object type should be 250 byte string. Users are referenced by their login.

Code:
items = db:getall([[
  SELECT login, MAX(created) accessed
  FROM user_logs
  WHERE failed IS NULL or failed=0
  GROUP BY login
]])

logs = {}

for _, item in ipairs(items) do
  logs[ item.login ] = os.date('%c', item.accessed)
end

grp.checkupdate('1/1/1', logs.admin)
grp.checkupdate('1/1/2', logs.some_other_user)
grp.checkupdate('1/1/3', logs.another_user)
Your support is just amazing guys, 

THANKS A MILLION  Big Grin
Reply


Forum Jump: