简体   繁体   中英

Worklight : how to set use addGlobalHeader for WL.Client.invokeProcedure calls

For WorkLight applications I don't see some cookie headers being sent to the server for basic WL.Client.invokeProcedure calls. How do you properly add cookie headers? Ideally, these would be global but I read that there may be issues using WL.Client.addGlobalHeader("Cookie"). procedure).

This is basically the code in Javascript:

var invocationData = {
    adapter : "data",
    procedure : procedure,
    headers : { "Cookie", "CookieData=val" }
    parameters : parms,
};
WL.Client.invokeProcedure(invocationData)

Edited: http://www-01.ibm.com/support/docview.wss?uid=swg21678099 "The WL.Client.addGlobalHeader API replaces the entire 'Cookie' header and destroys the session state."

Right now there is no way to add your own cookies to Worklight requests. Like your edit says, any Cookie header added using addGlobalHeader() gets replaced with only the cookies WL adds.

A feature request has been opened to see if this functionality could be added in future versions.

MFP 7.0.0 added a new API - WL.Client.setCookie() .

A usage example:

WL.Client.setCookie({
  name: 'cookieName',
  value: 'cookieValue',
  domain: 'google.com',
  path: '/', // all paths
  expires: 0 // never expires
}).then(function() {
  // callbacks go here
});

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