Getting previous value when retrieving from storage.get('key')

I’m trying to generate a random number whenever a button clicked and storing that in a variable and then storing that in storage.set(‘key’, value). And trying to get that value in another page using storage.get(‘key’). Then I’m getting the value which is generated previously. Can anyone help me to get the current value?

Please show us the relevant code you have.