src/Plugin/CookiePlugin.php
private function parse_cookie($line, $url){

		$host = parse_url($url, PHP_URL_HOST);
		
		$data = array(
			'name' => '',
			'value' => '',
			'domain' => $host,
			'path' => '/',
			'expires' => 0,
			'secure' => false,
			'httpOnly' => true
		);
		
		$line = preg_replace('/^Set-Cookie2?: /i', '', trim($line));
		
		// there should be at least one name=value pair
		$pairs = array_filter(array_map('trim', explode(';', $line)));
		
		foreach($pairs as $index => $comp){
		
			$parts = explode('=', $comp, 2);
			$key = trim($parts[0]);
			
			if(count($parts) == 1){
			
				// secure; HttpOnly; == 1
				$data[$key] = true;
				
			} else {
				
				$value = trim($parts[1]);
				
				if($index == 0){
					$data['name'] = $key;
					$data['value'] = $value;
				} else {
					$data[$key] = $value;
				}
			}
		}
		
		return $data;
	}
private function parse_cookie($line, $url){

		$host = parse_url($url, PHP_URL_HOST);
		
		$data = array(
			'name' => '',
			'value' => '',
			'domain' => $host,
			'path' => '/',
			'expires' => 0,
			'secure' => false,
			'httpOnly' => true
		);
		
		$line = preg_replace('/^Set-Cookie2?: /i', '', trim($line));
		
		// there should be at least one name=value pair
		$pairs = array_filter(array_map('trim', explode(';', $line)));
		
		foreach($pairs as $index => $comp){
		
			$parts = explode('=', $comp, 2);
			$key = trim($parts[0]);
			
			if(count($parts) == 1){
			
				// secure; HttpOnly; == 1
				$data[$key] = true;
				
			} else {
				
				$value = trim($parts[1]);
				
				if($index == 0){
					$data['name'] = $key;
					$data['value'] = $value;
				} else {
					$data[$key] = $value;
				}
			}
		}
		
		return $data;
	}
private function parse_cookie ( $ line , $ url ) { $ host = parse_url ( $ url , PHP_URL_HOST ) ; $ data = array ( 'name' => '' , 'value' => '' , 'domain' => $ host , 'path' => '/' , 'expires' => 0 , 'secure' => false , 'httpOnly' => true ) ; $ line = preg_replace ( '/^Set-Cookie2?: /i' , '' , trim ( $ line ) ) ; // there should be at least one name=value pair
 $ pairs = array_filter ( array_map ( 'trim' , explode ( ';' , $ line ) ) ) ; foreach ( $ pairs as $ index => $ comp ) { $ parts = explode ( '=' , $ comp , 2 ) ; $ key = trim ( $ parts [ 0 ] ) ; if ( count ( $ parts ) == 1 ) { // secure; HttpOnly; == 1
 $ data [ $ key ] = true ; } else { $ value = trim ( $ parts [ 1 ] ) ; if ( $ index == 0 ) { $ data [ 'name' ] = $ key ; $ data [ 'value' ] = $ value ; } else { $ data [ $ key ] = $ value ; } } } return $ data ; }
adapted from browserkit
adapted from browserkit