Each user, who has registered as affiliate has special link displayed on his "Affiliate Materials" page on Front-End under "My Account".
Usually affiliate place this link on another website in a advertisement banner. When this link is clicked, then user will see a regular website, but ID of user, who created that link (affiliate link) would be remembered in cookie/session based on setting in admin.
All orders, created during such website visit would also contain affiliate user's id, who would get commission after they are approved.