如何从应用程序目录外的外部本机php代码更新CI Session

I have buid a project in codeigniter and I set CI session with key USER and value 'ABCD'.

$this->load->library('session');
$this->session->set_userdata('USER','ABCD');

And now I put some native PHP code outside the application directory and from there I have to update the session data having key USER to value 'XYZ' .

I can not change the session used in CI as it is being implemented in many pages. I can only change to native PHP code.

I also tried to use curl by making a function like this to update session through CI and make a function setcisession() in my controller

function setcises($key,$val)
{
    $cSession = curl_init(); 
    curl_setopt($cSession,CURLOPT_URL,"http://www.example.com/controller/setcisession/$key/$val");
    curl_setopt($cSession,CURLOPT_RETURNTRANSFER,true);
    curl_setopt($cSession,CURLOPT_HEADER, false); 
    $result=curl_exec($cSession);
    curl_close($cSession);
}

My function in Controller to set session

function setcisession($key,$value)
{
    $this->load->library('session');
    $this->session->set_userdata($key,$value);  
}

but not luck I also tried

exec("wget --spider www.example.com/home/setcisession/$key/$val"); 

Edited: Actually, I create CI session when user login to web with key- USER and and store the emailid which is used by the website many place. And I had written social login code outside codeigniter application (in core php) directory and like to assign the email-id which returned from social login to CI SESSION Key-'USER' so that the website can identify the logedd in user

I know that I can do this by implementing social login code in CI

But I Want to know how can we set CI session from core php code residing outside codeigniter application directory