4

If I made a request on my server with $http I get the following response:

Request URL:http://www.test.tst/login
Request Method:GET
Status Code:200 OK
Request Headersview source
Accept:application/json, text/plain, */*
Accept-Encoding:gzip,deflate,sdch
Accept-Language:de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4
Connection:keep-alive
Cookie:JSESSIONID=349AD3AC797C6AB28121ADA1766FF4A2
Host:www.test.tst

i implemented it that way:

$scope.checkToken = function () {
            $http({method: 'GET', url: 'http://www.test.tst/login', params: {'action.code': 'LINK', 'linkparameter': $rootScope.token}}).
                success(function (data, status, headers, config) {
                    console.log($cookieStore.get('JSESSIONID'));
                }).
                error(function (data, status, headers, config) {
                    $location.path("/login");
                });
        }

can anybody tell me, why $cookieStore.get('JSESSIONID') is always undefined?

the cookie domain is the same as the domain my request is coming from.

2
  • possible duplicate of angularJS read response cookie empty Commented Sep 2, 2013 at 8:39
  • 1
    The duplicate mentioned by @Florian has been removed by author. Commented Oct 17, 2013 at 20:00

1 Answer 1

1

You should use the $cookie service, and not the $cookieStore $cookie provides access to the browser cookies; while $cookieStore allows you to store and retrieve values.

It means to access the cookies set by the server, you will use $cookie.$cookieStore.get() will allow you to access values you stored in your application, using $cookieStore.set() Just replace $cookieStore with $cookie in your code.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.