cx Posted May 4, 2009 Share Posted May 4, 2009 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"; Quote Link to comment https://forums.phpfreaks.com/topic/156769-send-cookies-with-fsockopen-in-php/ Share on other sites More sharing options...
kenrbnsn Posted May 4, 2009 Share Posted May 4, 2009 Please explain what you are trying to do. Ken Quote Link to comment https://forums.phpfreaks.com/topic/156769-send-cookies-with-fsockopen-in-php/#findComment-825552 Share on other sites More sharing options...
cx Posted May 4, 2009 Author Share Posted May 4, 2009 Login to remote page. Quote Link to comment https://forums.phpfreaks.com/topic/156769-send-cookies-with-fsockopen-in-php/#findComment-825553 Share on other sites More sharing options...
kenrbnsn Posted May 4, 2009 Share Posted May 4, 2009 Please post the code your using. You may have to use curl. Ken Quote Link to comment https://forums.phpfreaks.com/topic/156769-send-cookies-with-fsockopen-in-php/#findComment-825568 Share on other sites More sharing options...
cx Posted May 4, 2009 Author Share Posted May 4, 2009 $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.. Quote Link to comment https://forums.phpfreaks.com/topic/156769-send-cookies-with-fsockopen-in-php/#findComment-825599 Share on other sites More sharing options...
cx Posted May 4, 2009 Author Share Posted May 4, 2009 Please post the code your using. You may have to use curl. Ken Blind people can code that in binary and you tell me that i can't do it with fsockopen?? Quote Link to comment https://forums.phpfreaks.com/topic/156769-send-cookies-with-fsockopen-in-php/#findComment-825793 Share on other sites More sharing options...
premiso Posted May 4, 2009 Share Posted May 4, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/156769-send-cookies-with-fsockopen-in-php/#findComment-825855 Share on other sites More sharing options...
cx Posted May 4, 2009 Author Share Posted May 4, 2009 I know how to do it with curl. curl_setopt($ch, CURLOPT_COOKIEJAR, $path); Quote Link to comment https://forums.phpfreaks.com/topic/156769-send-cookies-with-fsockopen-in-php/#findComment-825869 Share on other sites More sharing options...
premiso Posted May 4, 2009 Share Posted May 4, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/156769-send-cookies-with-fsockopen-in-php/#findComment-825880 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.