In most cases, web resources have the same origin if they have the same schema (protocol), hostname (domain/subdomain), and port. Only in Internet Explorer, the port number is not considered a part of the origin.
Find out about cookie security flags, which are another web protection mechanism.