Recent Topics

Trying to understand how to determine if a "user" is logged in!

Started by on Jan 23, 2019 – Contents updated: Jan 30, 2019

Jan 23, 2019 19:49    

Hi...

Inspecting the codebase to get a better understanding of how it functions. Is there a way/attribute in a given tbl that I can inspect to see if a given user if logged into the system?

As far as I can tell, it appears that the process sets the $current_User->ID for a user when the user is logged in... I can't seem to find any tbl where this information is maintained...

Any pointers???

thanks

Jan 23, 2019 22:38

@tsmith

Can't log in without cookies so :
Cookies are used to store if a user is logged in, that has the user name and then that can be used to find the relevant user data from the database

Jan 24, 2019 01:19

The place where the server/DB remembers logged in users is the sessions table.

Jan 24, 2019 15:32

Hi

Took a look at the "evo_sessions" table.

As an example the "Admin" user has an ID -> 1.

If I inspect the evo_sessions tbl for the sess_user_ID=1, I have multiple rows. Of course the last row by the timestamp can be assumed to be the current user/session for the given user.

Is there a better approach?

There's the is_logged_in func ,which gets triggered off the current_User->ID but I can't seem to find the logic/code where this is actually set. I assumed that this was somewhere in the /htsrv/login.php (or the anon_async.php but I didnt see anything..

I also thought there might be a session var.. but nope..

For now I can get the "currentUser" name via the post from the login.. I could then use the loginName to get the userID and with that interrogate the evo_sessions to get the "latest" row which matches the userID and is the last/latest row by the timestamp.

Thoughts/comments?

thanks

Jan 30, 2019 01:57

There is no such thing as a "current session" for a user. A user can have multiple sessions open at the same time (in different browsers, or on different devices).


Form is loading...

RWD CMS – This forum is powered by b2evolution CMS, a complete engine for your website.