Jump to content

Recommended Posts

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

?>

Link to comment
https://forums.phpfreaks.com/topic/205926-automatic-login-to-another-website/
Share on other sites

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.

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.