Welcome Guest, Not a member yet? Register   Sign In
SESSION:Find current active users in my app???
#6

[eluser]Lorren[/eluser]
Unless I'm misreading, I think I see where the confusion is coming from.

The session library includes functionality to store extra 'meta' data w/ your other session data.

Code:
$this->session->set_userdata('some_name', 'some_value');

From: http://biffin.me/user_guide/libraries/sessions.html

When using a database to store session data, this data is stored in the 'user_data' column of the session table, as a serialized array.

Store your users' corresponding ID as user data in this way. The user_data will persist even when the session_id expires / changes.

As for your codes, I would store this in the user table, on the row of the user who's currently using the code pair.

I'm not sure how you handle your authentication, but I like to have a token associated with the user rows, which I store as user_data along-side the users' id. Every time a user is logged in or out, or requests a password change, or what-have-you, this token changes. If the system detects (on page-load) that the user row token doesn't match what's stored in the session, then it is assumed that the user has logged in at another location (or similar), and the system will then unset the session, effectively logging the user out from that location.

You could potentially use this same methodology with your application. When a user logs in with a code, store that information in both the session along-side the user id (w/ set_userdata) and in the user's table. When any user logs in, check the code that's used against the user table. If the code is found to be belonging to another user already, then unset the code column in that user's row, and set it in the new user's row. The old user's session will check invalidly as matching to their user row, and the system will log them out (if using a similar per-page authentication method as is described above).


Messages In This Thread
SESSION:Find current active users in my app??? - by El Forum - 10-12-2009, 09:13 AM
SESSION:Find current active users in my app??? - by El Forum - 10-12-2009, 11:51 AM
SESSION:Find current active users in my app??? - by El Forum - 10-13-2009, 12:46 AM
SESSION:Find current active users in my app??? - by El Forum - 10-13-2009, 12:47 AM
SESSION:Find current active users in my app??? - by El Forum - 10-13-2009, 09:00 AM
SESSION:Find current active users in my app??? - by El Forum - 10-13-2009, 01:31 PM
SESSION:Find current active users in my app??? - by El Forum - 10-14-2009, 01:26 AM
SESSION:Find current active users in my app??? - by El Forum - 10-14-2009, 11:46 AM
SESSION:Find current active users in my app??? - by El Forum - 10-15-2009, 01:09 AM



Theme © iAndrew 2016 - Forum software by © MyBB