If a customer visits my site and doesn't buy anything initially but then comes back later thru an affiliates referral id should the affiliate be credited with the sale? Or should there be no referral on the sale since the buyer visited my site first without using an affiliates referral id?
Right now it sets a cookie if one does not already exist, so it won't be overwritten, and if there is no affiliate referral then the cookie is set as no referral.
Many people would argue that you didn't close the sale on the first try, but the affiliate did on the second try. Therefore, the affiliate should get the commission.
It all depends on how you've setup your affiliate agreement. I've seen both ways done, but I have seen more giving credit to the affiliate. (It's the same issue as when someone comes through Affiliate A, doesn't buy, then comes through Affiliate B and buys.)
Or should there be no referral on the sale since the buyer visited my site first without using an affiliates referral id?
This sounds like you want to credit affiliates for the new visitors only (and only when they buy). I would never bother about such program. Not because I'm greedy but because it is almost impossible to make any money on it.