Forum Moderators: coopster

Message Too Old, No Replies

problem with a php login script using cookies

help to find problem with php script when using parked domain

         

cypm

5:20 am on Jun 18, 2005 (gmt 0)

10+ Year Member



Hello,

We are new to this site, but we are happy to be here, and hope that you guys can help us with a problem we are having with one of our websites.

we have one main domain that is linked to the ip is. As part of the website we have a login/registration system that work properly using cookies.

However we have a second domain that we have parked on top of this domain, but when a user pull the website using the parked domain the login script does not work it simply spits the user back into login.php.

We think this problem has something to do with the URL masking that is messing with the cookie setup and stoping the script from recognizing the user as log in.

When we are in a browser window and pullup the login page using the main domain, and do nothing else simply go from there and then type in the same browser window the adress to the login page using the parked domain, then the script works fine.

Does anyone has any ideas as to what could be wrong? We have being working on this for a while now, but cannot seem to find the problem. Any help would be greatly appreciated.

cypm

5:33 am on Jun 18, 2005 (gmt 0)

10+ Year Member



here is what a friend suggested

"The problem is the cookie. The cookies sound like there setup to download to the users pc once they access the domain. Allowing the login to work. If you access the login via the parked domain, you do not recive that cookie. There for, it sounds like a better idea to have the same page setup under a new account sot he cookies can funtion properly. You can try to make the cookied read off two domains, but I have never tried this, nor have I heard of anyone doing this."

is setting up a duplicate of all file the only way to make the cookie work with both domains then?

mcibor

9:32 am on Jun 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Do you want to use one cookie with two domains?

To make the cookie available on all subdomains of example.com then you'd set it to '.example.com'. The . is not required but makes it compatible with more browsers. Setting it to www.example.com will make the cookie only available in the www subdomain. Refer to tail matching in the spec for details.

setcookie("TestCookie", $value, time()+3600, "/~rasmus/", ".example.com", 1);

more here: [php.net...]

Best regards
Michal Cibor

craig1972

7:19 am on Feb 26, 2008 (gmt 0)

10+ Year Member



Sorry to rejuvenate this old thread, but a search on this site presented this thread which sounds relevant. And there's no other with an answer. Mcibor had asked:


Do you want to use one cookie with two domains?

Yes, this is exactly what I want to do. I run a service which is XYZ.com. But for user's preference, we also have XYA.com and XYB.com, both of which are parked on XYZ.com.

Now when a user logs in on XYZ.com, I want to set the cookie for XYA and XYB too. Is this not technically feasible? I am not talking about subdomains, I'm talking about parked domains.

Thanks for any idea!