handling a comma inside a cookie value using .net's (C#) System.Net.Cookie

后端 未结 2 1422
南旧
南旧 2020-12-15 22:46

I\'m creating a client to visit a website and log in + do some tasks automatically, however they recently updated their cookies to (for whatever reason...) contain a comma i

2条回答
  •  天涯浪人
    2020-12-15 23:13

    To handle the cookie, since a cookie is essentially a string, you may like to try URL Encoding the cookie value before setting it, and then Decoding it when you pull out the value.

    i.e.:

    Response.Cookies["Value1"] = Server.UrlEncode(sCookieValue);
    

    and similarly:

    string sCookieValue = Server.UrlDecode(Request.Cookies["Value1"]);
    

提交回复
热议问题