Magnets and SD Cards or Hard Drives.
Short Answer:
SD HDD vs Magnets - SD HDD and data survives.
Magnetic HDD vs Magnets - Data loss will occur. And Internal parts may get damaged.
More:
There are some terrible answers on the internet. I would like to get the answers corrected or improved just a little. A terrible answer that I found is that it worded that "magnets will not damage hard drives" -- but actually -- my answer is it can/will destroy the data if it is a magnetic hard drive. It might be ok if it is an SD Card but I can't fully support that answer even though I am never worried about having magnets and flash drives together in my pocket. I keep my credit card and money in my left pocket and keys in my right pocket, if I have a magnet I will keep it in my right pocket which is away from the credit card.
Magnets can destroy the data on any media that use magnetic storage such as magnetic hard drives. There are still magnetic hard drives or there are newer SD Hard Drives in some of today's computers and laptops. There is a magnetic hard drive in my laptop that I am using right now and I probably will upgrade to an SD Hard Drive soon to get improved HDD performance.
If a magnet swipes near by a magnetic hard drive it may not be noticeable at first if data loss has happen. It will depend on the strength of the magnet and how far away from the hard drive. The computer will probably seem to run just fine at first. But data loss could have happened. Probably won't be able to boot the OS anymore and probably won't be able to recover all the family photos. It just depends if the hard drive uses magnetic to store data and the strength/distance.
One of my favorite YouTuber Creator -- Brainiac75 -- had posted a video of an SD Card VS Monster Magnet and Induction Cooker. The SD Card and the data was still ok after being exposed to a strong magnet. The video is:
https://youtu.be/WhqKYatHW2E
There are other magnetic medias that are not used so much today for example floppy disks, vhs video tapes, cassette tapes, there are a lot. I remember taking a video class in middle school. We recorded plenty of skits. And at that time, the technology of that day was to store the video on VHS tapes. And I remember there was a big magnet device that was used to erase the vhs tapes, so we used that to erase the tape and record new skits. Sure ya we could just use the video camera to record over the old video, but for professional purpose is to erase the tapes then record.
Edit:
The rumor is that to destroy a hard drive and/or data by magnet, you need a really strong magnet that will lift cars. Incorrect. Watch this video:
https://youtu.be/ezAP1LINEMw
And there is another video out there some where that proves of data loss. The computer seemed to still be running fine. But errors popup while trying to open photos and files. And then it failed to boot up again.
There are posts on forums of users experiencing a broken chrome book after having magnets nearby it in class.