JQuery Ajax Call not setting cookie

I checked the request and saw that:

Set-Cookie:.AspNet.Cookies=AQAAANCMnd8BFdERjHoAwE_Cl-sBAAAAFyzOzXtC90-nkj7osKIxHgAAAAACAAAAAAAQZgAAAAEAACAAAAB68msx5mvbIc_UOFEpHKgyKg8z4X75MKKk5Notp79FeAAAAAAOgAAAAAIAACAAAAD8G4ZvSLWFoqp7TVme89yuoX0Kd7V6uYe-WEeeSoYClvAAAAB1vGrXcVvzq7uUYiruKLJiGBpZJBDcOL3PBMRYnHv3VT202hC-4J-U-GGoJlWQz3MrEoq_vmEoE3tbsn09AAX06HZrhBl5ZvyLiTkCcJaAT_xeX-6Uv6fDWMHpezJ_xrhE8nVjOj8oBI2HhIjymzD1CaWCriFqPOQKSoC6OLOHurRUcZ6J8LHeKcsWsc4hm6z6VD-GgzHyHAzZ7OgHX6NMsBpkQ_6VX7e-lo-fUx4RG6sJRIKPHbbFGm8hpfNzFCffbS8nuGC7SMu9zoQLGdDcZx0ulxlQcSxpcfbaaPbb3l1FsM9YZOipQNyLRDQtN-5AAAAA2D6u3avm-yI1tnz-xqBLBus26s2IRF2vuBzDEFkTbG5PPYHY2ijq5-xMzkNlVNsgloQ-XjKhmy9JiX4YLkMSjQ%3D%3D; path=/; expires=Mon, 30-Sep-2013 21:49:58 GMT; HttpOnly

but when I look at browser cookies, this is not set.

$.ajax({
            url: this.path + id,
            beforeSend: (xhr) => this.setAuth(xhr),
            type: 'GET'
        })....

Relevant information may be that its challenge is cross-origin. http://localhost:36859/before http://127.255.0.1:8061/.

Do I need to do anything else to set a cookie?

+4
source share
1 answer
    return $.ajax({
        url: this.path + id,
        beforeSend: (xhr) => this.setAuth(xhr),
        type: 'GET',
        crossDomain: true,
        xhrFields: {
            withCredentials: true
        }
    }).fail((xhr, status, error) => {  
        console.log(arguments);           
        notification.showErrorMessage("Error Loading", notification.getErrorDetail(xhr));
    });

xhrFields did the trick. An authentication cookie is sent by calling webapi.

+3
source

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


All Articles