public function onHeadersReceived(ProxyEvent $event){
	
		$request = $event['request'];
		$response = $event['response'];
		
		// does the response send any cookies?
		$set_cookie = $response->headers->get('set-cookie');
		
		if($set_cookie){
		
			// remove set-cookie header and reconstruct it differently
			$response->headers->remove('set-cookie');
			
			// loop through each set-cookie line
			foreach( (array)$set_cookie as $line){
			
				// parse cookie data as array from header line
				$cookie = $this->parse_cookie($line, $request->getUri());
				
				// construct a "proxy cookie" whose name includes the domain to which this cookie belongs to
				// replace dots with underscores as cookie name can only contain alphanumeric and underscore
				$cookie_name = sprintf("%s_%s__%s", self::COOKIE_PREFIX, str_replace('.', '_', $cookie['domain']), $cookie['name']);
				
				// append a simple name=value cookie to the header - no expiration date means that the cookie will be a session cookie
				$event['response']->headers->set('set-cookie', $cookie_name.'='.$cookie['value'], false);
			}
		}
	}