cookie removed when refresh page
<p>i'm developing a website using angularjs and nodeJS, my issue is that when is store an object in cookie, this object will still in cookie until i reload page and this is my code</p>

<pre><code>.service("Auth", function ($cookies, $rootScope) {
        var currentUser = null;
        return {
            set: function (data) {
                currentUser = data;
                $cookies.putObject("user", data, {
                    secure: true,
                    expires: (new Date(new Date().setMinutes(new Date().getMinutes() + 30))).toString()
                });
                $rootScope.currentUser = currentUser;

            }
            ,
            get: function () {
                return currentUser;
            }
            ,
            isLoggedIn: function () {
                if (currentUser) {
                    return true;
                } else {
                    return false;
                }
            }
            ,
            logOut: function () {
                $cookies.remove('user');
                // currentUser = null;
                $rootScope.currentUser = null;
            }
        }
    }
)
</code></pre>