dou12754 2011-09-11 21:57
浏览 65

从Android PHP登录获得响应

I'm trying to determine whether the user name and password I've sent to a php login form is valid. I've read some posts that suggest looking at the response text and checking for the title of the page that is returned. Other posts mention using a session ID in some way. Just what is the best way to detrmine if the user name/password combo is valid once I've posted to the form? Any help would be greatly appreciated. Thanks in advance.

Update...

I was able to resolve this issue using the following code snippet:

response = httpClient.execute(httpPost);
cookies = ((AbstractHttpClient) httpClient).getCookieStore ();
myCookie = cookies.getCookies ();
//  if cookies are empty, login did not work.
if (!myCookie.isEmpty ()) 
    { 
    for (int i = 0; i < myCookie.size(); i++) 
          { 
        String str = myCookie.get(i).toString(); 
        //  look for PHP session cookie and save it.
        if (str.contains ("PHPSESSID"))
            {
            phpsessid = myCookie.get (i).toString ();
            int index = phpsessid.indexOf("value");
            phpsessidGuid = phpsessid.substring(index+7, index+39);
            }
          } 
    }

Hope this helps others with the same problem.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
    • ¥30 深度学习,前后端连接
    • ¥15 孟德尔随机化结果不一致
    • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
    • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
    • ¥15 谁有desed数据集呀
    • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
    • ¥15 关于#hadoop#的问题
    • ¥15 (标签-Python|关键词-socket)
    • ¥15 keil里为什么main.c定义的函数在it.c调用不了