i created php page with these cookies :
setcookie("0","hello+how+are+you",time()+30);
in C# i wrote that code to read cookies :
string webaddr = "http://www.mywebsite.com";
string cookiesresult = "";
//----Establish Connection to web and get cookies [Commands]----//
HttpWebRequest httpwr = (HttpWebRequest)WebRequest.Create(webaddr);
httpwr.CookieContainer = new CookieContainer();
HttpWebResponse httpwrs = (HttpWebRes开发者_运维知识库ponse)httpwr.GetResponse();
//----Start Getting Cookies----//
foreach (Cookie cook in httpwrs.Cookies)
{
cookiesresult = cook.Value;
}
Console.WriteLine("Cookies Recieved : " + cookiesresult);
now cookies value should be : hello+how+are+you but instead value is : hello%2Bhowo%2areo%2you
so it exchanged + with o%2 and i don`t know what is the problem
The cookies are being URL Encoded, also referred to as percent-encoding. Use the HttpServerUtility.UrlDecode method to decode them.
When you create a cookie it turns all special characters into their html equivalent.
For example a google search: http://www.google.com/?q=hello%20there%20how%20are%20you
精彩评论