How to login into a site from another one?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
guarriman
Forum Commoner
Posts: 44
Joined: Thu Nov 03, 2005 4:11 am

How to login into a site from another one?

Post by guarriman »

Hi.

I've got 'foo1.com' where users log in by using PHP sessions. I store login and password hash into the session, and each time one user access a webpage, I check them.

But I've created 'foo2.com' and want users not to log in again on another login point, but using the 'foo1.com' login. I mean, if you are logged in 'foo1.com' you are also logged in 'foo2.com'. How to manage it? Must I create a webservice or something similar?

Thank you very much.
mentor
Forum Contributor
Posts: 100
Joined: Sun Mar 11, 2007 11:10 am
Location: Pakistan

Post by mentor »

for this you need to set the value for session.cookie_domain. in your login page, before initializing session put this line

ini_set ( 'session.cookie_domain', '.foo2.com' );

for more info visit http://www.php.net/manual/en/ref.sessio ... kie-domain
guarriman
Forum Commoner
Posts: 44
Joined: Thu Nov 03, 2005 4:11 am

Post by guarriman »

Hi.

I forgot to mention that 'foo1.com' and 'foo2.com' are on different machines, and that the 'users' table (which contains user+pass info) is placed on 'foo1.com'
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

You aren't allowed to set cookies for other domains. So, the next best thing is placing an identifier (like the session ID) in the URL's transferring the user between the servers.
User avatar
neel_basu
Forum Contributor
Posts: 454
Joined: Wed Dec 06, 2006 9:33 am
Location: Picnic Garden, Kolkata, India

Re: How to login into a site from another one?

Post by neel_basu »

guarriman wrote:Hi.

I've got 'foo1.com' where users log in by using PHP sessions. I store login and password hash into the session, and each time one user access a webpage, I check them.

But I've created 'foo2.com' and want users not to log in again on another login point, but using the 'foo1.com' login. I mean, if you are logged in 'foo1.com' you are also logged in 'foo2.com'. How to manage it? Must I create a webservice or something similar?

Thank you very much.
You Can Do It in 2 ways.
1. First Login On foo1 then after a Succesfull login on foo1 Use curl to loging on foo2.
2.Use Session Identifiers
I think Method 1 is The Siplest and Safest
User avatar
louie35
Forum Contributor
Posts: 144
Joined: Fri Jan 26, 2007 8:40 am
Location: Dublin
Contact:

Post by louie35 »

post the form values to the other site login page.
Post Reply