Cross-Domain Cookies

后端 未结 15 2546
抹茶落季
抹茶落季 2020-11-21 21:56

I have two webapps WebApp1 and WebApp2 in two different domains.

  1. I am setting a cookie in WebApp1 in the HttpResponse.
  2. How to read the same cookie fro
15条回答
  •  北荒
    北荒 (楼主)
    2020-11-21 22:49

    Read Cookie in Web Api

    var cookie = actionContext.Request.Headers.GetCookies("newhbsslv1");
    
    
                        Logger.Log("Cookie  " + cookie, LoggerLevel.Info);
                        Logger.Log("Cookie count  " + cookie.Count, LoggerLevel.Info);
    
                        if (cookie != null && cookie.Count > 0)
                        {
                            Logger.Log("Befor For  " , LoggerLevel.Info);
                            foreach (var perCookie in cookie[0].Cookies)
                            {
                                Logger.Log("perCookie  " + perCookie, LoggerLevel.Info);
    
                                if (perCookie.Name == "newhbsslv1")
                                {
                                    strToken = perCookie.Value;
                                }
                            }
                        }
    

提交回复
热议问题