简体   繁体   中英

send cookie inside request angularjs http get

I have the following http get , that I would like to send a cookie with a language on the request, but turns out with $cookieStore, it sends the cookie outside of the request

$cookieStore.put("language", "pt-PT");

I tried this as well

var myObject = {
    headers: { 'language': 'pt-PT'}
}//ignored

return $http.get(comm.endpoints.getEntityFinancialPosition, myObject );

In my debug I can see that this just created a new header that is not sent inside the cookie 在此处输入图片说明

The scope of the cookie is restricted with the domain option. If page domain is different than API domain cookie will not be sent when making a request. To fix that set the right domain for the cookie $cookieStore.put("language", "pt-PT", {domain: 'requestdomain.com'}) .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM