Force logout a user

How can i force logout a user? If i change users level from eg. Administrator to Member, i want to logout the user and then login him again to set the new level.

You may use a DB-based session. Add a username column. If you modify the permission level, you simply delete that user row from the session table.

1 Like

That’s it. Thanks

Hi everyone, old topic but, where can I read more about this? is this a Yii feature? How do I implement it? I couldn’t find anything about it here in the guide.

tomsea,

You just begins to use CDbHttpSession by enabling it in your config


'session' => array (

            'class' => 'CDbHttpSession',

            'connectionID' => 'db',

            'sessionTableName' => 'session',

        ),



After that all logged users will have a record in the "session" table. To force users logout you have to delete appropriate record from the table.

Going further you can customize this component by making your own (extend original one)