Connecting Tech Pros Worldwide Help | Site Map

Need autologin facility to other site.

nilayanand's Avatar
Newbie
 
Join Date: Nov 2006
Posts: 3
#1: Nov 26 '06
My page has the link to take user directly to report page of other site. Clicking report link ask user (in browser authentication dialog box) to submit user, password, before showing report page. Our site has the user password stored in database and I just want to submit user/password internally so user won’t be asked for it.
Is there any way to do it through php?


Thanks in advance
bno bno is offline
Newbie
 
Join Date: Nov 2006
Posts: 8
#2: Nov 27 '06

re: Need autologin facility to other site.


Quote:

Originally Posted by nilayanand

My page has the link to take user directly to report page of other site. Clicking report link ask user (in browser authentication dialog box) to submit user, password, before showing report page. Our site has the user password stored in database and I just want to submit user/password internally so user won’t be asked for it.
Is there any way to do it through php?


Thanks in advance

store inputted variables with POST method, or could use a session or a cookie to track logged in status?
swandi's Avatar
Newbie
 
Join Date: Nov 2006
Posts: 13
#3: Nov 27 '06

re: Need autologin facility to other site.


I think you could use curl
[PHP]
<?php
$url = "http://nm.del.ac.id/?act=login";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt ($ch, CURLOPT_POST, 1);
//to enable POST
curl_setopt ($ch, CURLOPT_POSTFIELDS,"name=name&password=password&lo g=1");
//set the post value, you need to know the post field in the other site
curl_exec($ch);
?>
[/PHP]
TheMadMidget's Avatar
Member
 
Join Date: Oct 2006
Posts: 98
#4: Nov 27 '06

re: Need autologin facility to other site.


cURL can pull the data, but can't follow the post via redirecting.
Newbie
 
Join Date: Nov 2006
Posts: 17
#5: Nov 28 '06

re: Need autologin facility to other site.


Quote:

Originally Posted by TheMadMidget

cURL can pull the data, but can't follow the post via redirecting.

ya same think i want.....it's perl it's possible using
mechanize; module folow link is there.any one konws auto login in php
TheMadMidget's Avatar
Member
 
Join Date: Oct 2006
Posts: 98
#6: Nov 28 '06

re: Need autologin facility to other site.


If all you want to do is login into a single page and I'm guessing that has it's own form that sends off. If you have the users enter the information that the other page request, basically mimic that page, you can use cURL twice and accomplish the goal. Use both right after each other in the same file and you can login then submit their form. Note: login via cURL does not always work, typically because the remote server check the referer or is trying to set cookies and doesn't because of security reasons.
Reply