Quick sloppy demo (HTML etc included for demo purposes)
<!DOCTYPE html><htmllang="en"><head><metacharset="UTF-8"><title>Session Demo</title></head><body><p>
When this page first loads, the first time you open it before clicking
any buttons--the background is white.
</p><p>
When you click red or green, then refresh the page, the color changes
to that. If you close the tab entirely and open a new
tab and open the url again--white again.
</p><p>
If you hit the yellow button and refresh, it's yellow. If you close
the tab like before, do a new one, open the page again--yellow!
</p><p>If you do yellow then green or red, and refresh, green or red
wins--until you close that tab and reopen it, even close the browser
and reopen it, and then it will be yellow... because you picked
yellow!</p><buttononclick="pickRed()"style="background-color: red; color: white;">Red!
</button><buttononclick="pickGreen()"style="background-color: green; color: white;">Green!
</button><buttononclick="setLocalStorageToYellow()"style="background-color: yellow;">Set localstorage to yellow
</button><script>if(sessionStorage.getItem("chosenBackgroundColor")!==null){document.body.style.backgroundColor=sessionStorage.getItem("chosenBackgroundColor");}elseif(localStorage.getItem("localBackgroundColor")!==null){document.body.style.backgroundColor=localStorage.getItem("localBackgroundColor");}// functions!functionpickRed(){sessionStorage.setItem("chosenBackgroundColor","red");}functionpickGreen(){sessionStorage.setItem("chosenBackgroundColor","green");}functionsetLocalStorageToYellow(){localStorage.setItem("localBackgroundColor","yellow");}</script></body></html>
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Quick sloppy demo (HTML etc included for demo purposes)