gsklee / ngStorage

localStorage and sessionStorage done right for AngularJS.
MIT License
2.33k stars 461 forks source link

prefix is not set correctly in sessionStorage #206

Closed cicoub13 closed 8 years ago

cicoub13 commented 8 years ago

I try to change prefix using setKeyPrefix. Everything is OK in localStorage (cicoub13-test = issue) but prefix is not set in sessionStorage (ngStorage-test = issue).

Config code :

$localStorageProvider.setKeyPrefix('cicoub13-');

Controller code :

    $scope.testLocal = function() {
        console.log('testLocal');
        $localStorage.test = 'issue';
    };

     $scope.testSession = function() {
        console.log('testSession');
        $sessionStorage.test = 'issue';
    };

Test with yo angular and version 0.3.10 of ngStorage

issue-ngstorage-prefix

egilkh commented 8 years ago

Okay. That is indeed strange. Will investigate.

egilkh commented 8 years ago

Wait.

You should need to do it for both $localStorageProvider and $sessionStorageProvider, as they are 2 different providers and services.

Can you give it a try?

$localStorageProvider.setKeyPrefix('cicoub13-');
$sessionStorageProvider.setKeyPrefix('cicoub13-');

And see if that doesn't fix it for you?

cicoub13 commented 8 years ago

It works for me, thanks for help. Maybe add examples for 2 providers in doc. Sorry for the issue.

egilkh commented 8 years ago

No need to be sorry! :)

Yes. I'll create an issue for adding explanation and examples in the readme.

phongca22 commented 7 years ago

Please note them into Document.