0

I have been doing some research regarding cookies, sessionStorage, localStorage, but come up with very little insight into $sessionStorage.

Where can I view $sessionStorage in Developer Tools (if one can)? Or is there and alternative, and even better way?

I am using AngularJs' $sessionStorage in my app to assist with user experience, keeping track of filters and dates etc.

I have looked for these parameters under Chrome's Application>>Local Storage, Session Storage Cookies and all other options, but cannot find my APP defines $sessionStorage values. They work though! :D

Update: Here is an example of the usage:

CookiesAlertController.$inject = ['$scope','$http','$sce','$sessionStorage','GetDataService'];

function showAlert() {
    if (!angular.isDefined($sessionStorage.cookiesAlertNotificationCount)) {
        $sessionStorage.cookiesAlertNotificationCount = 0;
    }
    if (angular.isDefined($sessionStorage.cookiesAlertNotification)) {
        if ($sessionStorage.cookiesAlertNotificationCount === false && $sessionStorage.cookiesAlertNotificationCount > 4) {
            $scope.cookiesAlertNotification = false;
        }
        else {
            $scope.cookiesAlertNotification = true;
        }
    }
    else {
        $scope.cookiesAlertNotification = true;
    }
}

$scope.closeNotification = function () {
    $scope.cookiesAlertNotification = false;
    $sessionStorage.cookiesAlertNotification = false;
    $sessionStorage.cookiesAlertNotificationCount = $sessionStorage.cookiesAlertNotificationCount + 1;
};
skwisgaar
  • 880
  • 2
  • 13
  • 31
onmyway
  • 1,435
  • 3
  • 29
  • 53
  • Mainly Chrome and some IE when needed – onmyway Apr 05 '17 at 10:05
  • 1
    Possible duplicate of [How to view or edit localStorage](http://stackoverflow.com/questions/9404813/how-to-view-or-edit-localstorage) – Debug Diva Apr 05 '17 at 10:13
  • @Rohit I don't think so. I can access and view the local and session storage just fine. The issue is; I cannot see my items used in Angular's $sessionStorage. – onmyway Apr 05 '17 at 10:15
  • 1
    Hi guys. I feel it is unnecessary to down vote my question. I believe I clearly indicated I am referring to Angular's `$sessionStorage` and not `$window.sessionStorage`. Please reconsider. – onmyway Apr 05 '17 at 15:42
  • Don't worry I upvoted your question! Your question is legit! – Abhishek Gautam Dec 13 '19 at 11:40

1 Answers1

2

$sessionStorage is an AngularJs service found at: https://github.com/gsklee/ngStorage

It allows you to read and write to $localStorage and $sessionStorage, making use of these stored parameters during the lifetime of your session.

You will not be able to view these $sessionStorage or $localStorage items via the dev tools, but you can view the values by assigning it to a variable in your code.

Example:

var whatIsInMyStorage = $localStorage; // or $sessionStorage; 

You can also clear these storage items by calling:

$sessionStorage.$reset();
$localStorage.$reset();

I hope this helps someone else.

skwisgaar
  • 880
  • 2
  • 13
  • 31
onmyway
  • 1,435
  • 3
  • 29
  • 53