Web Hosting Talk







View Full Version : hope this function exists... (php,javascript)


getbusy
02-04-2005, 06:35 PM
Hello,

I want to use an user-database for multiple websites + the users shouldn't have to login on every site they visit (logged in on one domain means logged in on all domains).

So.. I have http://myfirstdomain.com/myuserid.php (that file reads the cookie for myfirstdomain.com and echos the user id; so myuserid.php only contains "0" or "5" or "244" or ..). Only myfirstdomain.com can read the cookie.

On my seconddomain.com I want to run http://www.myfirstdomain.com/myuserid.php, the problem is that the enduser should open this domain and not the server (so it can't be done with fopen because the cookie wouldn't get read)



Is there any php command or javascript that could make this work?


This doesn't work: include(), fopen()

I think I might need the following commands,
ob_start();
$header = ob_get_contents();
ob_end_clean();


Hope someone can help me!. Thank you

cpscripts
02-05-2005, 12:17 AM
You should consider using session handling for this?

Please click here (http://www.php.net/manual/en/ref.session.php) for more information on php sessions.

Then all you would need to do is pass the session id to your other domains! It's either that or perhaps identify users by thier ip which is not really a great way to do things!

Good luck!

CPSCRIPTS

mitchlrm
02-05-2005, 12:59 PM
There are good security reasons why it is difficult to read cookies from another domain. You can manage this if they are sub-domains but not completely different domains.

getbusy
02-05-2005, 03:57 PM
yeah.. but I thought sessions only work on one domain?

Tomer
02-07-2005, 02:34 PM
Set mulitple cookies for each domain.