Just one session for one user

I want one user to have one session only. If user signs in again on some
other station, it should automatically log off from previous session.
I really dont know how to implement this.
Somebody please guide me. I am storing my session in DB.
Thanks.

On Jan 8, 2008, at 10:28 AM, Vapor … wrote:

I want one user to have one session only. If user signs in again on
some
other station, it should automatically log off from previous session.
I really dont know how to implement this.
Somebody please guide me. I am storing my session in DB.

You want to delete the rest of sessions for that user, but in a
regular setup of the AR session store the user_id associated to a
record is marshalled as session data.

You’d need to add a custom column user_id in the sessions table and
maintain that column somehow, for example in an after_filter in
ApplicationController. This solution is explained in The Rails Way.

– fxn