- msg_Dbg( p_access, "Sending Cookie %s", psz_cookie_content );
- if( net_Printf( VLC_OBJECT(p_access), p_sys->fd, pvs, "Cookie: %s\r\n", psz_cookie_content ) < 0 )
- msg_Err( p_access, "failed to send Cookie" );
+ const char * cookie = vlc_array_item_at_index( p_sys->cookies, i );
+ char * psz_cookie_content = cookie_get_content( cookie );
+ char * psz_cookie_domain = cookie_get_domain( cookie );
+ if( psz_cookie_content &&
+ /* Check to see if we are in the right domain */
+ ( !psz_cookie_domain || strstr( p_sys->url.psz_host, psz_cookie_domain ))
+ )
+ {
+ msg_Dbg( p_access, "Sending Cookie %s", psz_cookie_content );
+ if( net_Printf( VLC_OBJECT(p_access), p_sys->fd, pvs, "Cookie: %s\r\n", psz_cookie_content ) < 0 )
+ msg_Err( p_access, "failed to send Cookie" );
+ }
+ free( psz_cookie_content );
+ free( psz_cookie_domain );