title: Check if localStorage is available
body: <p>I know there has been many questions about checking for <code>localStorage</code> but what if someone manually shuts it off in their browser?  Here's the code I'm using to check:</p>
  
  <pre><code>localStorage.setItem('mod', 'mod');
  if (localStorage.getItem('mod') != null){
    alert ('yes');
    localStorage.removeItem('mod');
  } else {
    alert ('no');
  }
  </code></pre>
  
  <p>Simple function and it works.  But if I go into my Chrome settings and choose the option "Don't Save Data" (I don't remember exactly what it's called), when I try to run this function I get nothing but <code>Uncaught Error: SecurityError: DOM Exception 18</code>.  So is there a way to check if the person has it turned off completely?</p>
  
  <p>UPDATE:  This is the second function I tried and I still get no response (alert).</p>
  
  <pre><code>try {
    localStorage.setItem('name', 'Hello World!');
  } catch (e) {
    if (e == QUOTA_EXCEEDED_ERR) {
     alert('Quota exceeded!');
    }
  }
  </code></pre>