subdomain name as yii application-level parameters

Hi there,

how can I process a subdomain name and then set it as an application-level parameter.

For example: http://username.domain.com

I would like to take the username,look for the PK in the database and then set it as an yii application-level parameter.

So in every Controller instance I can access Yii::app()->params[‘user_ID’]

Thank you for any answers.

Philipp

Yii has a feature called "Parameterizing Hostnames", take a look here (at the bottom of the section).

If you don’t want to use that feature, you can attach to the onBeginRequest and process the subdomain-info before any controller gets loaded.

There are several ways to do it.