A cookie is a little bit of data which websites place on your computer. It has information in it which is read again by that website the next time you visit. It's often used as a way for sites to customize your visit based on what you did last time you were there. Cookies can have an expiration date.
In affiliate marketing, cookies are used to track your sales. When someone clicks through from your link, a cookie with a timestamp and your affiliate ID is set on their computer. Typically, if they leave the merchant site without buying right away but return and buy something the next day, as long as your cookie hasn't expired you'll get credit for the sale (even though the 2nd visit wasn't made through your link).
A 30 day cookie means the cookie won't expire for 30 days. Other things can affect this - some affiliate cookies can be overwritten with other affiliates' ids, or the visitor may run something on their PC which deletes all their cookies sooner.