Swipe key cards, like those used in hotels to access rooms, have a magnetic stripe on the back. This magnetic stripe contains many microscopic iron particles that are magnetized in a particular pattern. When a computer scans the stripe, it translates the pattern and receives the necessary information. If the particles become demagnetized, the pattern will be disrupted and a scanner won't be able to recognize it.
The Magnetic Stripe
Imagine that the stripe on the back of a swipe card is filled with tiny iron filings. These iron "filings" (which are actually microscopic particles) are arranged in a very specific way that's unique to each credit card or hotel key. When the magnetic stripe is swiped, the computer recognizes the pattern and communicates the signal back to its database. If it's your credit card, the information will be sent to your bank. If it's a hotel key, the door will open. Because these particles are made from iron, magnets can rearrange them, disrupting the pattern. So instead of a specific unique pattern, the computer will see a bunch of scrambled signals, and it will be unable to read your key card. This process is called demagnetization.
Magnets can and do cause swipe keys to become demagnetized. The stronger the magnet, the more likely the magnetic stripe is to become demagnetized. An MRI machine, for instance, will almost certainly scramble the magnetic stripe's iron particles into an unrecognizable mess. Another possibility is that the magnets in a purse's clasp will cause the card to become demagnetized. Wallets and billfolds also can have magnets in them which -- with enough exposure -- can demagnetize a swipe key. It's not always about the strength of the magnet, but rather the length of exposure to the magnet. Swipe keys that are exposed to magnets for a longer period of time are more susceptible to becoming demagnetized.
Credit Cards/Cell Phones
Some people believe that having one credit card next to another can cause them to become demagnetized. The theory behind this is that magnets cause demagnetization of magnetic stripes, and since magnetic stripes are in fact magnetized, this magnetic energy can cause another magnetic stripe to demagnetize. This is far from the truth however, and it would take an unprecedented amount of exposure for this to occur. Furthermore, the cards would have to be strip-to-strip for this entire time, and there's still little to no chance of the demagnetization process occurring. Another common myth is that cell phones cause swipe keys to demagnetize. Although some flip phones contain magnets that enable the phone to stay closed, most phones don't have strong enough magnets to have any effect on the magnetic stripes.
Physical damage to the magnetic stripe is a far more likely culprit for your device becoming demagnetized than magnets. A scratch to the magnetic stripe can cause a disruption in the iron particle pattern, resulting in an unreadable signal sent to the computer. Because key cards are often stored in wallets, purses or pockets with loose change, keys and lint, physical damage may well occur before any true demagnetization does. Although physical damage doesn't exactly demagnetize the stripe per se, it does ruin it, and the cashier or hotel clerk may see a "swipe key demagnetized" error when she runs your card through the computer.