Add common code for all pages

I need to add a piece of code for all pages

What is the proper method of adding it.

Currently i m using Controllers init methods to add that code but it is a code repeatition.

Suggest

Can you give more information.

What is the purpose of this code?

You could hook it up as an event to CApplication::onBeginRequest() (or onEndRequest(), whatever floats your boat)

I have to set variables on basis of session values

These variables will be used in further execution