- b2evolution CMS Support Forums
- b2evolution Support
- General Support
- [2.x] Making a cookie active on subdomains - HOW?`
1 bonka Feb 02, 2009 21:42
My b2evolution Version: 2.x
I am running multiple blogs on one server, and - as many others here are expressing - I am having trouble that the cookie set for the main domain just arent valid for the subdomains.
I found [url=http://www.danhulton.com/blog/2009/01/01/sharing-cookies-between-subdomains-in-kohana-php/]this function[/url] for rewriting the
http://URL
to
http://.URL
, this little dot being said to make the cookie valid also for the subdomains. The script is written for Kohana, and to be true, there are a couple of years since I was a master in this universe, and that vas Java and ASP.
So I have two questions.
Would this simple .htaccess rewrite work? And if so - what is invalid in the following argument?
$cookie_path = preg_replace( '#https?://[^/]+#', '', $baseurl );
$cookie_path = substr($cookie_path),strpos($cookie_path, '.'), 100;
Can't believe it should be so difficult to get a cookie valid for a couple of subdomains!!!
I have done a little research in the [url=http://manual.b2evolution.net/MultipleDomains]b2Evo Multiple Domains[/url], and this codes comes up:
Otherwise, in order to make your cookies, especially the SessionCookie, available across all your subdomains, you could explicitly set
$cookie_domain = '.example.com';
It seemed like a good idea, so I tried it. Checking the cookie - it is actually '.mydomainname.com', but that doesn't help me across subdomains... Losing my patience here... Help!
Lastly - this code is said to be included in the apache2.conf-file. I have an apache system, but where is this apache conf-file residing? Cant it find it nowhere it is supposed to be!
Sorry. I was a young programmer when the IT-bubble burst. Now I am doing something completely different :)
<VirtualHost *>
ServerName mydomain.com
ServerAlias *.mydomain.com
UseCanonicalName Off
DocumentRoot /home/mydomain/www
DirectoryIndex index.html index_multi.php
</VirtualHost>
3 waltercruz Feb 03, 2009 16:01
Keep reporting ;)
Ok. I just made it. Flicking around in settings for the last 4 hours, I finally uncommented a little strange code-snippet in basic_config.php
And suddenly everything worked.
Strangely enough, I had to log into the different subdomains, but at least the cookie-information finally stuck!
Thank god. And good night :)
PS: I will report back if this leads me into another mousetrap.