Topic: Help with subdomains cookies

Hi there,

I have one database, two forums on two different sites and I want my forums integrated in my site. The structure looks like this:

./
./forum <- hidden directory in root
./site1.com <- actual site
./site2.com <- actual site
./forum.site1.com <- just a redirect
./forum.site2.com <- just a redirect

the two subdomains points to the ./forum directory. That means they actually use the same config.php file. In that file I give them different settings, but how do i set their cookies correctly?

The best would be if all my forums could use the same cookie, but I don't think that's possible with this structure. But at least site1.com and forum.site1.com should use the same and likewise with site2.

The settings right now looks like this:

if(site1) $cookie_domain = '.site1.com';
else if(site2) $cookie_domain = '.site2.com';

$cookie_path = '/';

And right now I can only log in on my forum.site1.com and forum.site2.com and they use different cookies.

I hope that's enough to give you an idea of what to do.

Re: Help with subdomains cookies

According to the cookie specification, any cookie set for one domain, must not be sent to any other domain. Try to search in google some information about cross-domain cookies, perhaps you will find something useful.

Re: Help with subdomains cookies

Hi again,

I've made some research on the cross domain thing and it seems like it only works when you're linking from one site to the other. What I want is that my users should be logged in on both sites, when they are logged in.

I've found this (http://www.vbulletin.org/forum/showthread.php?t=139272) add-on to the vbulletin board and before I try to do the same, I just want to hear if it is possible. What is basicly does is to add a field in the options where you can enter multiple forum URLs, instead of just one.

Does it seem like a possible thing to do with PunBB?

Thanks in advance.

Re: Help with subdomains cookies

Ok, I've been looking in the code now and it seems like i can just set 2 cookies everytime a user logs in; one for .site1.com and one for .site2.com. Shouldn't that solve the problem?

If i change $cookie_domain to an array with the domains and iterate through them in forum_setcookie(). I'll try it out.

Re: Help with subdomains cookies

Weeelo wrote:

Ok, I've been looking in the code now and it seems like i can just set 2 cookies everytime a user logs in; one for .site1.com and one for .site2.com. Shouldn't that solve the problem?

You can set cookie only for domain, where requested page placed.