Custom User Authentication

(sorry this should have been posted in Yii 2.0 section!)

Hi! :)

I’ve been studying Yii Framework for a week, but now I don’t know what should be the way to achieve this:

I want a custom authentication mechanism, so that

  • on every request the credentials presented by the user (for example session id) are compared against the database (a table for user session with ids, ip addresses and so on). (I don’t want to use PHP session for storing any information)

  • I still want to be able to use the User Component accessing it via Yii::app.

At this moment I’m thinking of overriding some methods in CWebUser like login, maybe setstate?

Can someone point me in the right direction?

Much appreciated,



To be able to use the database to store the session you could use CDbHttpSession class. There is also an extension which adds additional checks (like IP and User Agent)

thank you :)