写了一个天涯登录的程序,现在登录有点问题,天涯登录有点奇怪,登录之后的cookie在jsp页面里面实现:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="http://passport.tianya.cn:80/" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="expires" content="0" />
<title>登录中......</title>
<script>
document.cookie='user=w=testtest&id=121212121&f=1;expires='+(new Date(new Date().getTime()+2592000*1000)).toGMTString()+';path=/;domain=tianya.cn';
document.cookie='temp=k=250364072&s=&t=1318418231&b=8a895b6e0eb48e13abdf0758a9caa672&ct='+parseInt(new Date().getTime()/1000)+'&et='+(parseInt(new Date().getTime()/1000)+2592000)+';expires='+(new Date(new Date().getTime()+2592000*1000)).toGMTString()+';path=/;domain=tianya.cn';
document.cookie='sso=r=1386759670&sid=&wsid=E4827F21A852121F07D1EF264EFF553D;expires='+(new Date(new Date().getTime()+2592000*1000)).toGMTString()+';path=/;domain=tianya.cn';
document.cookie='right=web4=n&portal=n;expires='+(new Date(new Date().getTime()+2592000*1000)).toGMTString()+';path=/;domain=tianya.cn';
document.cookie='temp4=rm=5a9eba45e6cb8b51e5cbe465a456f187;expires='+(new Date(new Date().getTime()+2592000*1000)).toGMTString()+';path=/;domain=tianya.cn';
</script><script type="text/javascript" src="http://passport.tianyaclub.com/domain.jsp?cookieTime=1318418231&portalValue=&rightCookie=false&rmCookieCode=5a9eba45e6cb8b51e5cbe465a456f187&isActivatedUser=&idWriter=121212121&writer=testtest&intKey=250364072&chvSysGradeList=&sysGrade=&domain=tianyaclub.com&flag=72e1c5d077295b13bc2f7ddd642fde36&rmCode=true&rmFlag=1&wsid=E4827F21A852121F07D1EF264EFF553D&r=1386759670"></script>
<script type="text/javascript" src="http://passport.hainan.net/domain.jsp?cookieTime=1318418231&portalValue=&rightCookie=false&rmCookieCode=5a9eba45e6cb8b51e5cbe465a456f187&isActivatedUser=&idWriter=121212121&writer=testtest&intKey=250364072&chvSysGradeList=&sysGrade=&domain=hainan.net&flag=72e1c5d077295b13bc2f7ddd642fde36&rmCode=true&rmFlag=1&wsid=E4827F21A852121F07D1EF264EFF553D&r=1386759670"></script>
<script type="text/javascript" src="http://passport.hiholiday.com/domain.jsp?cookieTime=1318418231&portalValue=&rightCookie=false&rmCookieCode=5a9eba45e6cb8b51e5cbe465a456f187&isActivatedUser=&idWriter=121212121&writer=testtest&intKey=250364072&chvSysGradeList=&sysGrade=&domain=hiholiday.com&flag=72e1c5d077295b13bc2f7ddd642fde36&rmCode=true&rmFlag=1&wsid=E4827F21A852121F07D1EF264EFF553D&r=1386759670"></script>
</head><body>
<script>
location.href="http://my.tianya.cn";
</script>
</body></html>
类似上面的地方,按说应该是登录成功了
但是我一访问http://my.tianya.cn,就是未登录状态
请教各位大侠,如何处理?

解决方案 »

  1.   

    使用什么组件?估计访问http://my.tianya.cn时,没处理好组件的请求头及cookie。
      

  2.   

    使用的idhttp,估计是这个问题,但是不知道怎么处理了
      

  3.   


      with IdHTTP do begin
        Request.Accept:=
        Request.ContentType:=    
        Request.Host:=    
        Request.Referer:=    
        Request.UserAgent:=
        Request.AcceptEncoding:=
        Request.URL:=
        Request.ContentVersion:=
        Cookie:=
        //根据抓包分析得出的信息,设置好上述等号右侧,接着按下面那样发包即可:
        Request.CustomHeaders.Clear;
        Request.RawHeaders.Values['Cookie']:=Cookie;
        try
          Get('http://my.tianya.cn', RespData);//RespData为TStringStream,用来存放返回的信息。
        except
        end;
      end;
      

  4.   

    我就是没找到相应的问题,他的cookie好像比较复杂,我找了几个,好像还是不对,我用的是idhttp与idcookiemanager相结合
      

  5.   

    用ie正常登陆和访问http://my.tianya.cn来截包,不就可以看到它访问http://my.tianya.cn时提交的cookie是什么了吗?
      

  6.   

    cookie都没处理好,难怪你说“但是我一访问http://my.tianya.cn,就是未登录状态”了!
      

  7.   

    乐意的话,把你的工程简化一下发来,我帮你一起分析问题所在。[email protected]