src/Thybag/Auth/SharePointOnlineAuth.php
protected function extractAuthCookies($result){

		$authCookies = array();
		$cookie_payload = '';

		$header_array = explode("\r\n", $result);

		// Get the two auth cookies
		foreach($header_array as $header) {
			$loop = explode(":",$header);
			if (strtolower($loop[0]) == 'set-cookie') {
				$authCookies[] = $loop[1];
			}
		}

		// Extract cookie name & payload and format in to cURL compatible string
		foreach($authCookies as $payload){
			$e = strpos($payload, "=");
			// Get name
			$name = substr($payload, 0, $e);
			// Get token
			$content = substr($payload, $e+1);
			$content = substr($content, 0, strpos($content, ";"));

			// If not first cookie, add cookie seperator
			if($cookie_payload !== '') $cookie_payload .= '; ';

			// Add cookie to string
			$cookie_payload .= $name.'='.$content;
		}

	  	return $cookie_payload;
	}
protected function extractAuthCookies($result){

		$authCookies = array();
		$cookie_payload = '';

		$header_array = explode("\r\n", $result);

		// Get the two auth cookies
		foreach($header_array as $header) {
			$loop = explode(":",$header);
			if (strtolower($loop[0]) == 'set-cookie') {
				$authCookies[] = $loop[1];
			}
		}

		// Extract cookie name & payload and format in to cURL compatible string
		foreach($authCookies as $payload){
			$e = strpos($payload, "=");
			// Get name
			$name = substr($payload, 0, $e);
			// Get token
			$content = substr($payload, $e+1);
			$content = substr($content, 0, strpos($content, ";"));

			// If not first cookie, add cookie seperator
			if($cookie_payload !== '') $cookie_payload .= '; ';

			// Add cookie to string
			$cookie_payload .= $name.'='.$content;
		}

	  	return $cookie_payload;
	}
protected function extractAuthCookies ( $ result ) { $ authCookies = array ( ) ; $ cookie_payload = '' ; $ header_array = explode ( "\r\n" , $ result ) ; // Get the two auth cookies foreach ( $ header_array as $ header ) { $ loop = explode ( ":" , $ header ) ; if ( strtolower ( $ loop [ 0 ] ) == 'set-cookie' ) { $ authCookies [ ] = $ loop [ 1 ] ; } } // Extract cookie name & payload and format in to cURL compatible string foreach ( $ authCookies as $ payload ) { $ e = strpos ( $ payload , "=" ) ; // Get name $ name = substr ( $ payload , 0 , $ e ) ; // Get token $ content = substr ( $ payload , $ e + 1 ) ; $ content = substr ( $ content , 0 , strpos ( $ content , ";" ) ) ; // If not first cookie, add cookie seperator if ( $ cookie_payload !== '' ) $ cookie_payload .= '; ' ; // Add cookie to string $ cookie_payload .= $ name . '=' . $ content ; } return $ cookie_payload ; }
extractAuthCookies
Extract Authentication cookies from SP response & format in to usable cookie string

@param $result cURL Response
@return $cookie_payload string containing cookie data.
extractAuthCookies Extract Authentication cookies from SP response & format in to usable cookie string