I store sessions in my database and I'd like to store a session_id
with a user when they log in. How do I determine what a user's session
id is?
session.session_id
The reason I want to do this is because I'd like to display users
currently logged in.
session.session_id won't help here as it applies to the current user only.
If I can link a session to a user in my database, then I can check the
updated_at column
in the sessions table and determine who is active.
Is this the correct way to go about doing this?
There was a similar discussion about this previously. Basically you already
have access to the user session in the AR Store. You just need a way to
differentiate a user session from anonymous ones, if you have both session
types.
It might be possible to add a user_id column to the AR Store table and
populate the column when a user logs in. Alternatively, record users in a
separate user_table. You will have more flexibility in storing and managing
user info with this approach.