【问题标题】:Cookie was not setted未设置 Cookie
【发布时间】:2013-06-30 16:37:21
【问题描述】:

我使用 asp.net xss 脚本。一页发送一个帖子,而不是得到一个cookie。 在标题中,我读取了 cookie 返回,但浏览器没有设置它。 所以 document.cookie 为空

标题:

Set-Cookie:token=12ccc584-9f14-4c07-bbd9-0deba07b2a8e; expires=Fri, 30-Aug-2013 16:33:53 GMT; path=/

我在后端允许这些标头:

HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", 

HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", localost");
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Credentials", "true");



$.ajax(
            {
                url: "http://localhost:49670/api/authentication",
                type:"post",
                data: loginDTO,
                success: function() {
                    console.log("works");
            console.log("cookies: ", document.cookie);
            },
            error: function(request, status, error){
                console.error(request.responseText);
                },
                xhrFields: {
                  withCredentials: true
               }
            });

为什么没有设置 cookie?

【问题讨论】:

    标签: php javascript jquery asp.net xss


    【解决方案1】:

    因为你写的是“localost”而不是 localhost?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-10-10
      • 2018-06-22
      • 2021-10-21
      • 2012-02-11
      • 2016-02-12
      • 2011-11-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多