CONFIG modification


What is the recommended way of extending the $CONFIG array? I need to add an url of my server with a static content to serve the images and other files for my elgg theme.

I have prepared such a solution in the init function of my theme:

function mytheme_init() {
        global $CONFIG;       
        $staticurl = explode("/", $CONFIG->wwwroot);
        $CONFIG->staticurl = "http://static.".$staticurl[2]."/";

And it works but I do not like this code to be invoked by every request to my website. Is there a way to invoke it only once per every user session?