As our day-to-day lives move deeper into the online world, it’s increasingly important to prepare for what happens to our digital assets after we die. Much of the email, social media accounts, photographs, books, music and other digital files stored in the cloud are likely to have sentimental value for our loved ones (and sometimes monetary value as well). But unless we plan ahead, they may not be able to get to those files.

One reason, according to Jim Lamm, an estate planning and tax attorney with Gray Plant Mooty in Minneapolis, is that current federal law about private digital assets is a big problem. Unless a loved one plans ahead, “you're not going to be able to get at emails and social media posts that are private,” he explains.

This is true even if you know the deceased person's online passwords. Here’s why: The Stored Communication Act, which protects the privacy of electronic communications, can prevent someone, even a spouse, from gaining access to email accounts, social media postings and documents in the cloud without explicit written permission. Also, says Lamm, the Computer Fraud and Abuse Act could make someone who accesses your accounts after your death guilty of a crime.

Related: Is Your Insurance Company Using Social Media to Snoop on You?

Preventing digital "ghosts"

Only nine states have laws to address the issue of digital assets after death, according to the Uniform Law Commission (ULC), a Chicago-based non-profit that drafts model legislation. The ULC recently finalized the Revised Uniform Fiduciary Access to Digital Assets Act. This proposed law would give legal authority for executors and other fiduciaries — individuals authorized to hold assets in trust for another party — to manage digital assets as part of an estate plan.

“This is a law that is sorely needed,” says Benjamin Orzeske, ULC's chief counsel.

Related: What Happens to Your Facebook Account After You Die?

What you can do

Despite the legal quagmire around digital assets, you can make sure anyone you want to have access to your digital assets will be able to. It just takes planning.

“This is something that catches people off-guard,” said Evan Carroll, author of "Your Digital Afterlife." “Much of the challenge is we don’t like thinking about our own demise," he says, "so we don’t prepare for it.” He outlines several steps you should take to protect your digital assets (and presence) after your death.

Take stock. Create an inventory of your digital assets, from email accounts to music accounts. Lamm offers a downloadable form to help with your personal digital audit.

Archive your content. Back up your computer and other devices. If you have an online back-up service, be sure to include the account information in your inventory.

Document your wishes. Make it known what you want to happen to your digital assets after your death. This should be included in your will or in a digital addendum to your will or estate plan. Identify who you want to be able to access each asset as well as which accounts should be deleted.

Choose a digital executor. Select someone to carry out your wishes regarding your digital assets and put this in writing in your will or living trust (or in an addendum to it). Give the person your passwords, but don't include them in your will, since it will eventually become a public document. Instead, consider using a password management service.

Related: How to Complain on Social Media Without Getting Sued (or Worse)

Daniel S. Levine is an award-winning journalist who heads the Levine Media Group and hosts The Bio Report and RARECast podcasts. He was an editor of The Burrill Report and worked for the Oakland Tribune, Adweek, the San Francisco Business Times and other publications.