Welcome Guest, Not a member yet? Register   Sign In
List all sessions

Hello !
I'm trying to list all sessions data active in order to display a page where the user can consult all members connected to the website. Is that possible ?
I let the default FileHandler Driver. Documentation seems to say that it can be slow... but not so much.
The session interface seems to be exclusively dedicated to the manipulation of a session related to only one specific user[url=https://codeigniter.com/user_guide/libraries/sessions.html#id16][/url].

I try to find some other post discussing this common (?) issue but I didn't find anything except an "alluserdata" function belonging to codeigniter 3.

Thanks !

You won’t be able to do this using the Session Library because it is explicitly for a single session. If you know you are using FileHandler then you could get the directory from your Session Config file and then scan all the files. You probably would need to read each on in to get things like valid timestamps and content. Check out how the Session Library handler does that and you can probably mimic it:

I would not call this a “common” issue, for what it is worth. Smile If I were implementing this I would probably do it outside of Session, personally - something like a login or “last active” timestamp in the database for each user so you could query them quickly.

Hi, You could use a database table to store session_id(), a last_active timestamp and any other required data (e.g. user_id).

(This post was last modified: 07-07-2021, 01:09 PM by Gary.)

I'm with paulkd on this one... using a database table is pretty simple and sidesteps the (purposeful) isolation between sessions PHP guarantees.

When I implemented it, it was as an after-though, and then only because it was so simple to do (I already have a table that keeps tabs on who's signed in, when they signed in, from where, and things like that... so, in my case (where only the total is wanted), it's a simple conditional COUNT, but it would be simple enough to change the COUNT to a SELECT).

Thank you guys !!

Theme © iAndrew 2016 - Forum software by © MyBB