setItem
and removeItem
doesn't return any value. Thus you are getting undefined
. Also note removeItem
only accept one parameter.
Reference, Here is function sign for above methods
setItem(key:string, data:string):void
This public method stores data via specified key. Please note that if key was already stored, it will overwrite it. Another thing to consider is that if we store a key, and via sessionStorage.key(0) we obtain that key, then we store another key/data and finally we store again the first key, sessionStorage.key(0) will return the second key/data stored, and not the first one.
removeItem(key:string):void
This public method simply removes a key and related data from the storage.