I want to store some information in localstorage of a browser when the page is refreshed or the user exits the page for future use. I figured that I'd use some JavaScript to detect the event and store the state of the page visit.
Now my predicament is: shall I use Onbeforeunload or Onunload method to accomplish this objective?