Codeigniter:从配置访问会话

I am making an application using Codeigniter which requires URL changes before login and after login I want all the URLs before login with http:// and after login my base_url should be with https://.

So basically, what I want to access the session in config and then by using the session variable I can able to change the base_url format.

so please help me out to access the session with config file OR any alternative of this.

$config['base_url'] = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "https" : "http");
$config['base_url'] .= "://".$_SERVER['HTTP_HOST'];
$config['base_url'] .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);