Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function auto_login($userName = null, $userPassword = null ){
- //CURLOPT_COOKIEJAR
- $this->load->library('Curl');
- //post values
- $a_post = array(
- 'usr' => $userName,
- 'pwd' => $userPassword
- );
- $cookiesFile = $_SERVER['DOCUMENT_ROOT'].'/myCookies.txt';
- $handle = fopen($cookiesFile, 'w+');
- fclose($handle);
- $params = array(
- CURLOPT_HEADER => 1,
- CURLOPT_FOLLOWLOCATION => 1,
- CURLOPT_COOKIEJAR => $_SERVER['DOCUMENT_ROOT'].'/myCookies.txt',
- CURLOPT_COOKIEFILE => $_SERVER['DOCUMENT_ROOT'].'/myCookies.txt'
- );
- $url = $this->config->item('ma_url').'?module=system&action=login';
- $response = $this->curl->simple_post($url, $a_post,$params);
- //$this->curl->debug();
- $lines = explode("\n", $response);
- foreach($lines as $l){
- if(preg_match("/Set-Cookie/", $l)){
- $regCookie = $l;
- }
- }
- header($regCookie);
- header('location: '.$this->config->item('ma_url').'?module=management&action=view_account');
- //unlink($cookiesFile);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement