我正在制作一个登录网站的项目,而不是立即注销并重新开始。那么我的问题是cookies 我很不确定如何正确注销然后重新发送。关闭应用程序并重新启动它会使用户再次登录,因此其明显的 cookie 将被清除。
private void Form1_Load(object sender, EventArgs e)
{
WebRequest request;
string postData;
byte[] byteArray;
Stream dataStream;
while (true)
{
try
{
HttpWebRequest httpWReq = (HttpWebRequest)WebRequest.Create("http://www.********/index.php");
ASCIIEncoding encoding = new ASCIIEncoding();
postData = "param=example¶m=0¶m=bigboy";
byte[] data = encoding.GetBytes(postData);
httpWReq.Method = "POST";
httpWReq.ContentType = "application/x-www-form-urlencoded";
httpWReq.ContentLength = data.Length;
httpWReq.KeepAlive = false;
httpWReq.CookieContainer = new CookieContainer();
using (Stream stream = httpWReq.GetRequestStream())
{
stream.Write(data, 0, data.Length);
stream.Close();
}
}
catch (Exception err)
{
Console.WriteLine(err.Message);
}
}
}
可以做些什么来实现这样的循环过程?