Show TOC

Adding Cookies to a RequestLocate this document in the navigation structure

To add cookies to a request for authentication, use the header object that is passed to the get/sendRequest functions.  

Only the cookie name and value should be set this way.  The other pieces of the cookie (domain, path, and so on) are set automatically based on the URL the request is made against.  The cookie is treated as a session cookie and sent on future requests as appropriate.  The API examples below show an example of how to set a cookie with the header object.

var successCallback = function( result ){
     if( result.status === 200 ) {
        Response text: " + result.responseText );
     } else {
          alert("Not success, response status:
        " + result.status);

var failureCallback = function( error ) {
     alert("Error! Code: " + error.errorCode + "\n" + error.description + "\nNative error code: " + error.nativeErrorCode );

// setting a cookie with a request
var header = {cookie: "customCookieName=customCookieValue;anotherName=AnotherValue"};

sap.AuthProxy.sendRequest("POST", "", header, null, successCallback, failureCallback);