Returned the code to use jstorage (since it is a more universal solution -and it also works with objects)