PHP Classes

About cookies

Recommend this page to a friend!

      PHP HTTP protocol client  >  All threads  >  About cookies  >  (Un) Subscribe thread alerts  
Subject:About cookies
Summary:Cannot accessing after login
Messages:2
Author:arief aprilianto
Date:2008-09-07 18:46:46
Update:2008-09-07 19:00:56
 

  1. About cookies   Reply   Report abuse  
Picture of arief aprilianto arief aprilianto - 2008-09-07 18:46:46
Mr. Manuel,

I'm an Indonesian, sorry for my bad English.
I was using your class since 4 months ago. It's very help me to build some application web-based on my office(Indonesia Telecommunication,Inc).

Before, there is no problem with my code(with your class).
But yesterday, i found some errors. I don't know why?
Maybe web-server that I access was updraded..

First, I give you my code that I success to login on this site..

<?php
require("http.php");

set_time_limit(0);
$http=new http_class;
$http->timeout=0;
$http->data_timeout=0;
$http->debug=0;
$http->html_debug=0;
$http->user_agent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";
$http->follow_redirect=1;
$http->redirection_limit=5;
$http->exclude_address="";
$http->prefer_curl=0;



$url="http://os3.divre5.telkom.co.id/redirect.php";
$error=$http->GetRequestArguments($url,$arguments);
$arguments["RequestMethod"]="POST";
$arguments["PostValues"]=array(
"crew_id"=>"660325",
"password"=>"660325"
);
//$error=$http->Open($arguments);
//$error=$http->SendRequest($arguments);
//$http->Close();

//$url="http://os3.divre5.telkom.co.id/?mode=RadMgt&func=usageDetail&next=1&setKey1=".$key1."&setKey2=".$data[$b]."@telkom.net&setKey3=0";
// $error=$http->GetRequestArguments($url,$arguments);




// $arguments["Header"]["Referer"]="http://os3.divre5.telkom.co.id/?mode=&func=home";
echo "<H2><LI>Opening connection to:</H2>\n<PRE>",HtmlEntities($arguments["HostName"]),"</PRE>\n";
flush();
$error=$http->Open($arguments);

if($error=="")
{
$error=$http->SendRequest($arguments);
if($error=="")
{
echo "<H2><LI>Request:</LI</H2>\n<PRE>\n".HtmlEntities($http->request)."</PRE>\n";
echo "<H2><LI>Request headers:</LI</H2>\n<PRE>\n";
for(Reset($http->request_headers),$header=0;$header<count($http->request_headers);Next($http->request_headers),$header++)
{
$header_name=Key($http->request_headers);
if(GetType($http->request_headers[$header_name])=="array")
{
for($header_value=0;$header_value<count($http->request_headers[$header_name]);$header_value++)
echo $header_name.": ".$http->request_headers[$header_name][$header_value],"\r\n";
}
else
echo $header_name.": ".$http->request_headers[$header_name],"\r\n";
}
echo "</PRE>\n";
echo "<H2><LI>Request body:</LI</H2>\n<PRE>\n".HtmlEntities($http->request_body)."</PRE>\n";
flush();

$headers=array();
$error=$http->ReadReplyHeaders($headers);
if($error=="")
{
echo "<H2><LI>Response headers:</LI</H2>\n<PRE>\n";
for(Reset($headers),$header=0;$header<count($headers);Next($headers),$header++)
{
$header_name=Key($headers);
if(GetType($headers[$header_name])=="array")
{
for($header_value=0;$header_value<count($headers[$header_name]);$header_value++)
echo $header_name.": ".$headers[$header_name][$header_value],"\r\n";
}
else
echo $header_name.": ".$headers[$header_name],"\r\n";
}
echo "</PRE>\n";
flush();

echo "<H2><LI>Response body:</LI</H2>\n<PRE>\n";
for($data='';;)
{

$error=$http->ReadReplyBody($body,1000);

if($error!=""
|| strlen($body)==0)
break;

$data .= $body;
}

echo "</PRE>\n";
flush();
}
}
$http->Close();
}
if(strlen($error)){
echo "<CENTER><H2>Error: ",$error,"</H2><CENTER>\n";
}
echo $data;
?>


It is success with result like this:

Opening connection to:
os3.divre5.telkom.co.id
Request:
POST /redirect.php HTTP/1.1
Request headers:
Host: os3.divre5.telkom.co.id
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
Content-Type: application/x-www-form-urlencoded
Content-Length: 30

Request body:
crew_id=660325&password=660325
Response headers:
http/1.1 200 ok:
date: Sun, 07 Sep 2008 18:34:30 GMT
server: Apache/2.0.52 (Red Hat)
x-powered-by: PHP/4.3.9
expires: Thu, 19 Nov 1981 08:52:00 GMT
cache-control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
pragma: no-cache
content-length: 5932
connection: close
content-type: text/html; charset=UTF-8

  2. Re: About cookies   Reply   Report abuse  
Picture of arief aprilianto arief aprilianto - 2008-09-07 18:57:25 - In reply to message 1 from arief aprilianto
But, after trying to request another page after this login..
It seem failed..
And my code is : (same as before but I remove ("//" - comment sign)

<?php
require("http.php");

set_time_limit(0);
$http=new http_class;
$http->timeout=0;
$http->data_timeout=0;
$http->debug=1;
$http->html_debug=0;
$http->user_agent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";
$http->follow_redirect=1;
$http->redirection_limit=5;
$http->exclude_address="";
$http->prefer_curl=0;



$url="http://os3.divre5.telkom.co.id/redirect.php";
$error=$http->GetRequestArguments($url,$arguments);
$arguments["RequestMethod"]="POST";
$arguments["PostValues"]=array(
"crew_id"=>"660325",
"password"=>"660325"
);
$error=$http->Open($arguments);
$error=$http->SendRequest($arguments);
$http->Close();

$url="http://os3.divre5.telkom.co.id/?mode=RadMgt&func=usageDetail&next=1&setKey1=".$key1."&setKey2=".$data[$b]."@telkom.net&setKey3=0";
$error=$http->GetRequestArguments($url,$arguments);




echo "<H2><LI>Opening connection to:</H2>\n<PRE>",HtmlEntities($arguments["HostName"]),"</PRE>\n";
flush();
$error=$http->Open($arguments);

if($error=="")
{
$error=$http->SendRequest($arguments);
if($error=="")
{
echo "<H2><LI>Request:</LI</H2>\n<PRE>\n".HtmlEntities($http->request)."</PRE>\n";
echo "<H2><LI>Request headers:</LI</H2>\n<PRE>\n";
for(Reset($http->request_headers),$header=0;$header<count($http->request_headers);Next($http->request_headers),$header++)
{
$header_name=Key($http->request_headers);
if(GetType($http->request_headers[$header_name])=="array")
{
for($header_value=0;$header_value<count($http->request_headers[$header_name]);$header_value++)
echo $header_name.": ".$http->request_headers[$header_name][$header_value],"\r\n";
}
else
echo $header_name.": ".$http->request_headers[$header_name],"\r\n";
}
echo "</PRE>\n";
echo "<H2><LI>Request body:</LI</H2>\n<PRE>\n".HtmlEntities($http->request_body)."</PRE>\n";
flush();

$headers=array();
$error=$http->ReadReplyHeaders($headers);
if($error=="")
{
echo "<H2><LI>Response headers:</LI</H2>\n<PRE>\n";
for(Reset($headers),$header=0;$header<count($headers);Next($headers),$header++)
{
$header_name=Key($headers);
if(GetType($headers[$header_name])=="array")
{
for($header_value=0;$header_value<count($headers[$header_name]);$header_value++)
echo $header_name.": ".$headers[$header_name][$header_value],"\r\n";
}
else
echo $header_name.": ".$headers[$header_name],"\r\n";
}
echo "</PRE>\n";
flush();

echo "<H2><LI>Response body:</LI</H2>\n<PRE>\n";
for($data='';;)
{

$error=$http->ReadReplyBody($body,1000);

if($error!=""
|| strlen($body)==0)
break;

$data .= $body;
}

echo "</PRE>\n";
flush();
}
}
$http->Close();
}
if(strlen($error)){
echo "<CENTER><H2>Error: ",$error,"</H2><CENTER>\n";
}
echo $data;
?>


And It returned:

Connecting to os3.divre5.telkom.co.id
Resolving HTTP server domain "os3.divre5.telkom.co.id"...
Connecting to HTTP server IP 10.96.2.179 port 80...
Connected to os3.divre5.telkom.co.id
C GET /?mode=RadMgt&func=usageDetail&next=1&setKey1=2&[email protected]&setKey3=0 HTTP/1.1
C Host: os3.divre5.telkom.co.id
C User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
C
S HTTP/1.1 302 Found
S Date: Sun, 07 Sep 2008 18:56:33 GMT
S Server: Apache/2.0.52 (Red Hat)
S X-Powered-By: PHP/4.3.9
S Set-Cookie: PHPSESSID=4406385c2b1008d651a3340d1091d7f4; path=/
S Expires: Thu, 19 Nov 1981 08:52:00 GMT
S Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
S Pragma: no-cache
S location: http://os3.divre5.telkom.co.id/?func=login&msg=needAcces
S Content-Length: 0
S Connection: close
S Content-Type: text/html; charset=UTF-8
S
Disconnected from os3.divre5.telkom.co.id



The "location-page" that I request return a Failed Login indication.

Please, help to fix my problem..