I making an assumption what line throws the error, but your code is assuming the following line successfully finds the item it's looking for. You don't make any attempt to validate getItem actually found an item.
var datos = sessionStorage.getItem(guardaDNI);
Well, getItem is failing to find an item, so it returns null. Now on the very next line, you're trying to use a property on an object that doesn't exist, or is null.