[I have assumed you are talking about an indesign ExtendScript script, and not a CEP script]
LocalStorage - You have access to pretty much the whole harddrive, so you could easily create some storage scripts that create and store information in a specific folder <somePath>/localStorage/docName/ store information here anyway you want.
SessionStorage - As above, but you could register for the DocClose event, and at that point go through the sessionStorage location and remove all the files.
These would probably have to be coded by yourself as I don't think there is anything out there that would enable this.
As for the ID, I am not sure what you are trying to achieve, is this from a script, or default value?