Jump to content

Recommended Posts

This is the http header.

HTTP/1.1 302 Found Connection: close Set-Cookie: server_id=en36; expires=Wed, 03-Jun-2009 09:30:21 GMT; httponly Location: http://xxxxxx.xxx/login.php?sid=26c8...t=0223722e41eb Content-type: text/html; charset=utf-8 Content-Length: 0 Date: Mon, 04 May 2009 09:30:21 GMT Server: lighttpd/1.4.19

 

And error what i get is something like this.

You do not accept cookies

 

If you want to login, you have to accept session cookies. This secures your account against abuse.

 

Well i tried sending cookies with fputs(), but haven't had any luck yet..

Cookie: server_id=en36; expires=Wed, 03-Jun-2009 09:30:21 GMT;

 

$met = POST index.php?action=login HTTP/1.1\r\nHOST: host.xx\r\nAccept: */*\r\nContent-Type: application/x-www-form-urlencoded\r\nUser-Agent: Mozilla 4.0\r\nContent-Length: ".strlen($data)."\r\nConnection: close\r\n\r\n".$data."\r\n\r\n";

Link to comment
https://forums.phpfreaks.com/topic/156769-send-cookies-with-fsockopen-in-php/
Share on other sites

$data = "user=myuser&clear=true&password=my_pass&server=36";
$met = "POST index.php?action=login HTTP/1.1\r\nHOST: host.net\r\nAccept: */*\r\nContent-Type: application/x-www-form-urlencoded\r\nUser-Agent: Mozilla 4.0\r\nContent-Length: ".strlen($data)."\r\nConnection: close\r\n\r\n".$data."\r\n\r\n";
$fp = fsockopen("host.net",80);
fputs($fp,$met);
echo fread($fp,1024);


 

Then it will print this out

 

HTTP/1.1 302 Found Connection: close Set-Cookie: server_id=en36; expires=Wed, 03-Jun-2009 12:56:02 GMT; httponly Location: http://host.net/login.php?sid=c99ac0ed1c39&secret=ee824500e5d4 Content-type: text/html; charset=utf-8 Content-Length: 0 Date: Mon, 04 May 2009 12:56:02 GMT Server: lighttpd/1.4.19

 

Then i use explode() command to take out this http://host.net/login.php?sid=c99ac0ed1c39&secret=ee824500e5d4

And use it as url with file_get_contents().

 

Problem is with cookies, it keeps telling me that i have to enable cookies..

Blind people can code that in binary and you tell me that i can't do it with fsockopen??

 

Why not ask one of them what their secret is?

 

Use the right tools for the job. Just because you can "hammer" a nail in with a rock does not mean you should. There is a more efficient and better tool called a "hammer". curl was built for what you want to do, why not use it?

 

Curl allows you to save cookies so it looks like they are enabled. Look into it.

I know how to do it with curl.

curl_setopt($ch, CURLOPT_COOKIEJAR, $path);

 

So what is with this fascination with fsockopen?

 

If you must pursue this I would suggest reading the user comments at fsockopen. As it seems there may be people who found out how to do cookies with it.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.