making localstorage expire?
making localstorage expire?
max4ever
Posts: 45Questions: 0Answers: 0
I was having problems with a column bVisible not being applied, then i cleared localstorage and it worked. I am wondering how to make the user's browsers clear their localStorage data when i commit the changes to the production web site. Since it looks like it never expires http://stackoverflow.com/questions/2326943/when-do-items-in-html5-local-storage-expire
I was thinking maybe adding the current month in the key of the item, this way each month the settings would be refreshed? But that would leave a lot of old junk on the browsers(probably negligible to performance ?)
This is my code
[code]
oTable = $('#visualizzazione').dataTable(
{
"fnStateSave": function (oSettings, oData) {
localStorage.setItem( 'DataTables_'+window.location.pathname+$('div.login span:eq(0)').text().split(' ').join('')+"1",JSON.stringify(oData) );
},
"fnStateLoad": function (oSettings) {
return JSON.parse( localStorage.getItem('DataTables_'+window.location.pathname + $('div.login span:eq(0)').text().split(' ').join('')+"1") );
},
....
[/code]
I was thinking maybe adding the current month in the key of the item, this way each month the settings would be refreshed? But that would leave a lot of old junk on the browsers(probably negligible to performance ?)
This is my code
[code]
oTable = $('#visualizzazione').dataTable(
{
"fnStateSave": function (oSettings, oData) {
localStorage.setItem( 'DataTables_'+window.location.pathname+$('div.login span:eq(0)').text().split(' ').join('')+"1",JSON.stringify(oData) );
},
"fnStateLoad": function (oSettings) {
return JSON.parse( localStorage.getItem('DataTables_'+window.location.pathname + $('div.login span:eq(0)').text().split(' ').join('')+"1") );
},
....
[/code]
This discussion has been closed.
Replies
I'm thinking of making localStorage the default storage method for DataTables 1.10 (not quite 100% certain I will yet, but likely), and this will implement exactly that kind of method.
Allan
Allan