267
Views
10
Comments
Last_login in Users entity
Question
Hello everyone.

I'm using last_login field to get last time user loged in.
The problem is: this field is always being updated during the session. Even if don't use the web application.

I tried this on different environments and I hadn't this issue.
I have community edition installed on my machine and server is running on my machine too.

Is it normal?

Thank you!
2018-06-08 15-13-44
Ricardo Lopes
Staff
Additional info: on my machine I have 7.0.1.7 version installed.
I tried on 7.0.1.5 version and it works fine (different server).
2012-03-16 12-21-09
João Rosado
Staff
Hi Ricardo,

The last_login date is only changed when Login actions are called.
The applications that are running on the different machines are the same?
What user provider you using (Users/Enterprise Manager)?

Regards,
João Rosado
2018-06-08 15-13-44
Ricardo Lopes
Staff
Hi João.
Yes, it's the same application running in different environments.
I'm using Users.

Regards
2015-05-05 08-49-02
Seth

Is there a short-cut built-in function to obtain the user's Last_Login other than getting it through this method which I suspect can slow down the Application's performance:

GetUser(GetUserId()).User.Last_Login?


Or is this method the quickest and best method from the App performance point of view?

2019-11-12 17-31-26
Justin James
 
MVP

Seth wrote:

Is there a short-cut built-in function to obtain the user's Last_Login other than getting it through this method which I suspect can slow down the Application's performance:

GetUser(GetUserId()).User.Last_Login?


Or is this method the quickest and best method from the App performance point of view?

There isn't any built-in method that I know of, but if there was, it would do exactly what you wrote, since the DB is the data store of record for that information.

How often are you getting this data that you are concerned about performance of calling GetUser(GetUserId())?

J.Ja


2015-05-05 08-49-02
Seth

Justin James wrote:

Seth wrote:

Is there a short-cut built-in function to obtain the user's Last_Login other than getting it through this method which I suspect can slow down the Application's performance:

GetUser(GetUserId()).User.Last_Login?


Or is this method the quickest and best method from the App performance point of view?

There isn't any built-in method that I know of, but if there was, it would do exactly what you wrote, since the DB is the data store of record for that information.

How often are you getting this data that you are concerned about performance of calling GetUser(GetUserId())?

J.Ja


4 times in 4 different places. Would it be better upon login that I read this value into a Session variable instead of fetching it each time the user opens specific screens this funciton is called? I thought using session variables would be a little bad from an optimised code perspective. Or do I misunderstand the use of Session variables?


Thanks


2019-11-12 17-31-26
Justin James
 
MVP

Seth wrote:

Justin James wrote:

Seth wrote:

Is there a short-cut built-in function to obtain the user's Last_Login other than getting it through this method which I suspect can slow down the Application's performance:

GetUser(GetUserId()).User.Last_Login?


Or is this method the quickest and best method from the App performance point of view?

There isn't any built-in method that I know of, but if there was, it would do exactly what you wrote, since the DB is the data store of record for that information.

How often are you getting this data that you are concerned about performance of calling GetUser(GetUserId())?

J.Ja


4 times in 4 different places. Would it be better upon login that I read this value into a Session variable instead of fetching it each time the user opens specific screens this funciton is called? I thought using session variables would be a little bad from an optimised code perspective. Or do I misunderstand the use of Session variables?


Thanks



4 DB reads of that little record is NOTHING, unless you are doing this 10,000 times a minute or something. I would not spend another moment of time worrying about this. :) And yes, putting it in Session isn't a good use of session (funny, I am working on an article about that now).

J.Ja

2020-11-30 14-38-19
Miguel Sousa

Hello,

If your concern is performance or the number of times you are executing the query, you just need an identification for that specific session, to be the input of a cached action that retrieves the Login information. If that action has cache for some period of time (Eg: 20m), you will disable it everytime you change the input value (change your session). Having that in mind, in this way you don't execute the query everytime you use the action to get that values :)


Kind regards



2015-05-05 08-49-02
Seth

Miguel Sousa wrote:

Hello,

If your concern is performance or the number of times you are executing the query, you just need an identification for that specific session, to be the input of a cached action that retrieves the Login information. If that action has cache for some period of time (Eg: 20m), you will disable it everytime you change the input value (change your session). Having that in mind, in this way you don't execute the query everytime you use the action to get that values :)


Kind regards




Much appreciated

2015-05-05 08-49-02
Seth

Thanks a ton for the reassurance

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.