本帖最后由 vbnet10 于 2014-2-1 17:24 编辑
[C#] 纯文本查看 复制代码 public partial class Form1 : Form
{
HttpHelper http = new HttpHelper();
string cookie;
public Form1()
{
InitializeComponent();
}
//获取登陆信息
private void button1_Click(object sender, EventArgs e)
{
HttpItem item = new HttpItem()
{
URL = "http://localhost:88/TextGuest8.6/login.php",
Postdata = "action=login&username=admin888&password=123456&time=0",
Method = "post",
ContentType="application/x-www-form-urlencoded",
};
HttpResult result = http.GetHtml(item);
string htmlStr = result.Html;
cookie = result.Cookie;
textBox1.Text = htmlStr;
textBox2.Text = cookie;
}
private void button2_Click(object sender, EventArgs e)
{
HttpItem item = new HttpItem()
{
URL = "http://localhost:88/TextGuest8.6/member.php",
Method = "get",
ContentType = "application/x-www-form-urlencoded",
Cookie = textBox2.Text
};
HttpResult result = http.GetHtml(item);
string htmlStr = result.Html;
cookie = result.Cookie;
textBox1.Text = htmlStr;
textBox2.Text = cookie;
}
}
第一次登陆成功 ,我把cookie 放在textbox2中, 然后第二次登陆时候 我吧textbox2.text 放入 item .cookie 中 去访问需要验证cookie的页面
结果提示非法登陆, 我测试是自己写的一个 php的网站, 出现非法登陆是因为没有cookie['username']这个cookie 但是 这个cookie已经获取到了 兵第二次访问这个页面时候 也在textbox 中赋值给 item.cookie了
|