AngularJS cookie response value

if I made a request on my server with $ http I followig answer:

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 

How can I read "Cookie: JSESSIONID = 349AD3AC797C6AB28121ADA1766FF4A2"?

thanks

+4
source share
2 answers

You can use ngCookies . To do this, you need to include angular-cookies.js and ngCookie in your module.

Then you can enter $ cookie and get cookie via get function

 <script src="angular-cookies.js"> 

And in your Js

 angular.module('app', ['ngCookies']).controller('Test', ['$cookies', '$scope', function($cookies, $scope) { $scope.value = $cookies.get('JSESSIONID'); } ]); 
+6
source

$ cookie provides a .get function, which is $ cookieScope

If you use $ cookies, you should simply use $ cookies.JSESSIONID

Angular $ cookie

and

Angular $ cookieStore

-one
source

Source: https://habr.com/ru/post/1499638/


All Articles