0

This morning when I got to work and started my application all of a sudden it did not work anymore. I traced the issue back to the $cookieStore not working.

Has anyone experienced the same problem before? I am a bit at loss on what to search for the problem, as you can see from my console after I added a debugging break. The cookieStore is not saving anything:

enter image description here

Edit: Some more Info: I tested the same app on a different PC and it does the same in Chrome or IE. So I concluded that my libraries might be broken. So I re-downloaded 1.4.9 Angular and ngCookies. And it still does the same, no cookies are being written. I had an older on-line version that seems to work fine and write the cookies. How can I do a whole folder compare of all the files and folders to see where the problem is coming from? I am thinking a library broke it. Nothing in my Version Control shows code affecting the cookies in anyway

My Login Controller:

app.controller('LoginController', function ($rootScope, $scope, $cookieStore, $state, AuthenticationService, $timeout, $http, apiserv) {

        $scope.dataLoading = false;         
        $scope.error = $rootScope.message;
        $rootScope.globals = [];
        $cookieStore.remove('globals');
        $cookieStore.remove('auth');

        $scope.login = function () {
            $scope.dataLoading = true;
            var url = apiserv + "api.login.php?username=" + $scope.username + "&password="+$scope.password;
            $http({url: url}).then(function (rs) {
                console.log(rs.data);
                if (rs.data.success) {
                    var auth = rs.data.auth;
                    $rootScope.globals = {
                        currentUser: rs.data
                    };
                    $cookieStore.put('globals', $rootScope.globals);
                    $cookieStore.put('auth', auth);
                    debugger; // Where I took the above screenshot
                    $state.go('app.sites');
                } else {
                    $scope.error = rs.data.message;
                    $scope.dataLoading = false;
                }
            });

        };
    }
);
johan
  • 998
  • 6
  • 20

1 Answers1

1

I found the problem. I added this line to my index.html and it broke the cookies

<script>document.write('<base href="' + document.location + '" />');</script>

DON'T USE BASE... note to self (all the BASE are not belong to us :)

johan
  • 998
  • 6
  • 20