21

can user disable the HTML5 sessionStorage just how he can disable cookies?

Also is sessionStorage will valid till page refresh? I mean what session actually mean, is it page refresh?

2
  • Well there are still users out there with old browsers that don't support HTML5 storage.
    – nnnnnn
    Commented Jul 26, 2013 at 13:35
  • In Firefox, you can disable sessionStorage.
    – Pieter
    Commented Jul 26, 2013 at 13:36

3 Answers 3

39

Yes. HTML5 sessionStorage (and localStorage) can be disabled, and the data can also be cleared.

It is easy to prevent browsers from accepting localStorage and sessionStorage.

  • In FireFox: Type “about:config” in your address bar and hit enter to view your internal browser settings. Scroll down to „dom.storage.enabled“, right click on it and hit „Toggle“ to disable the DOM Storage.

  • In Internet Explorer: Select “Extras” -> “Internet Options” -> “Advanced” Tab -> Go to “Security” -> uncheck “Enable DOM-Storage”

  • In Chrome: Open “Options” and select “Under the Hood” Tab. Click on “Content settings…”, select “Cookies” and set “Block sites from setting any data”.

Also note: There are some browser security plugins/extras/add-ons that will prevent localStorage. If localStorage / sessionStorage is vital to your page operation you should attempt a test read-write.

Regarding your other question: sessionStorage will survive a page refresh. localStorage will persist between browsing sessions and survive a browser restart.

8

can user disable the HTML5 sessionStorage just how he can disable cookies?

A User can either clear the cookies or Disallow any website from setting the cookie for themselves.Every browser has that option.

For Example-:Block Cookies

I mean what session actually mean, is it page refresh?

First of all,its not a page refresh

Most simple analogy:Session is a token which allows the user to visit any area of a web app.This token is valid untill the browser close.The moment you close the browser all the session data will get cleared.

So what if i want my data to persist a little longer,Say i want permanently(considering that user have not cleared cookies) store some value on my users browser.

LOCAL STORAGE:Local storage allows the data to persist beyond the browser close.So when the user comes back,we can use that data in our application.We can set the expiry for it.We can clear it when we want.

NOTE:IE7 + support for SessionStorage and LocalStorage

Conventional cookie storage:This is our good old way of storing some data on client.All browsers support it.But the problem is they provide too less space.

  • A cookie provides 4kb space and for every domain there is a limit of around 15-20 cookies. LocalStorage and SessionStorage comes to our rescue.They provide quite good space. Different browsers have different capacity.

  • IE(10 mb)...Surprise surprise

  • Mozzilla(5 mb)

  • Chrome(2.5 mb)

So,basically i can use localStorage if i want the data to persist beyond browser close and SessionStorage if i want the data to persist with in the browser close.

There are some js availabe also..

  1. jStorage DOCUMENTATION
  2. persist.js DOCUMENTATION
3
  • stackoverflow.com/questions/8498357/… Commented Jul 28, 2013 at 5:27
  • 11
    ... so, can user disable html5 sessionStorage?
    – Nicu Surdu
    Commented Mar 19, 2014 at 9:33
  • 1
    He asks if you can turn of SesionStorage and you tell him he can turn off cookies? that is not what he asked :joy:
    – Jean-Paul
    Commented Apr 14, 2020 at 13:57
1

sessionStorage is used for session-based data. It is erased when the tab is closed according to the standard. You should use localStorage to persist across tab/window closings. Of course browsers can always not support these features or disable them, so you should handle that edge case to ensure your site remains functional. The best way to do this is to revert back to using cookies or use a compatibility library like this one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.