dahype
-
Posts
6 -
Joined
-
Last visited
Never
Posts posted by dahype
-
-
I still can figure it out, can somebody help please?
thanks
-
Then, you need to make 3 separate cURL requests for each operation. One to login to the site, one to fill in the form and one to submit the form.
Ok, so for the index.php i need to make 3 request,
the first with $url = "example.com/index.php"
the second ?
the third with $url = "example.com/index.php" and $POSTFIELDS correctly set for the login process.
Did i get it right? I don't understand what the second request will contain.
thx
-
sorry for the question, i am quite new to it: how do i update my cookie info every time?
After each request you need to update your cookie info, and maintain it, failure to do so could cause a "logout" if the session identifier changes. Are you sure your cookie jar/file is being written correctly?
-
and how do i set the cookie for the www.example.com ?
Hi dahype,
It may be that you first have to the second website's root (www.example.com) and set the cookie there before you attempt anything else.
Might be worth a go.
-
Hello buddies,
i am working on a php that must
1.login to a website with user/password
2.fill in a second form inside this website
3.submit & get the result
My script actually can login but i get "rejected" after some second with the message that my session is over.
This is probably a cookie problem but i can't figure it out.
The script is the following:
<?php
$cookie_jar = tempnam('/','cookie');
$url = "http://example.com/index.php";
$POSTFIELDS = 'field1=value1&username=myuser&password=mypass';
$reffer = "https://example.com/";
$agent = "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)";
$cookie_file_path = "/";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$POSTFIELDS);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_REFERER, $reffer);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
$result = curl_exec($ch);
$url = "https://example.com/second.php?fromlogin=true";
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,null);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_REFERER, null);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
$result2 = curl_exec($ch);
$url = "https://example.com/third.php";
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,null);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_REFERER, "https://example.com/second.php?fromlogin=true");
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
$result3 = curl_exec($ch);
$file = tempnam('/','output');
$handle = fopen("output", "w+");
fwrite ( $handle , "one:".$result."\ntwo:".$result2."\nthree:".$result3 );
fclose($handle);
curl_close($ch);
?>
and what i have in output file is
one:<html><head><meta http-equiv="Refresh" content="5;url=https://example.com/index.php?part=timeout"></head><body></body></html>
two:<html><head><meta http-equiv="Refresh" content="0;url=index.php?part=timeout"></head><body></body></html>
three:function Set_Cookie(name, value, expires, path, domain, secure )
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );
/*
if the expires variable is set, make the correct
expires time, the current script below will set
it for x number of days, to make it for hours,
delete * 24, for minutes, delete * 60 * 24
*/
var expires_date = new Date( today.getTime() + (expires) );
document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}
Set_Cookie("windowname", '', 2147483647, '/', '', '');
does anybody know where i am doing it wrong?
Php - Curl redirection problem
in PHP Coding Help
Posted
Hello buddies, i got some problems writing a php that has to login to a https page and then perform some actions.
When i run it from my hosting i get this error
Not Found
The requested URL /hosting.com/page.php was not found on this server.
I used LiveHTTP Headers add-on for mozilla to get the steps right and i saw that "page.php" is the page to which the user is redirected to after logging in. Obviously that page cannot be found on MY hosting because it's on the server where i do the log in.
How can i solve that?
The code i am using for that is the following:
any ideas? thanks