georgebaker Posted June 26, 2010 Share Posted June 26, 2010 I need to log into the site below every day. I have looked for some code to do that and i found the code below which should log me in automatic, but it doesn't work. Can you see what's wrong with the code or do you have another way to do this. Thanks or your help in advance. Webside: Using Authentication And file_get_contents() | #! code username: xxxxxx password: yyyyy1 here is the code: <?php $username = 'xxxxxx'; $password = 'yyyyy1'; $url = 'http://www.fracsoft.com/'; $context = stream_context_create(array( 'http' => array( 'header' => "Authorization: Basic " . base64_encode("$username:$password") ) )); $data = file_get_contents($url, false, $context); // echo $data ?> Quote Link to comment https://forums.phpfreaks.com/topic/205926-automatic-login-to-another-website/ Share on other sites More sharing options...
premiso Posted June 26, 2010 Share Posted June 26, 2010 Are you wanting to have it login you in on your computer, or to just simply log you in to keep an account active? Because if you are wanting it to log you in on your local computer, I doubt you can do it, unless you possible use cURL and can tell a browser locations to search for cookie files (which I do not know if it will do). But you may want to look into cURL, which should have more functionality and provide you with better means of controlling / receiving data getting sent to the site. Quote Link to comment https://forums.phpfreaks.com/topic/205926-automatic-login-to-another-website/#findComment-1077575 Share on other sites More sharing options...
georgebaker Posted June 26, 2010 Author Share Posted June 26, 2010 Thank you for your reply premiso. I want the script to log me in automatic when i click on a link from my website. I have tried cURL but i cannot get it to work. I cannot find a good toturial on how to set it up on a NON ssl server Quote Link to comment https://forums.phpfreaks.com/topic/205926-automatic-login-to-another-website/#findComment-1077585 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.