Welcome to Geeklog, Anonymous Monday, November 25 2024 @ 08:57 pm EST

Geeklog Forums

cookie problems with multiple subdomains


Status: offline

thelusiv

Forum User
Junior
Registered: 05/21/04
Posts: 23
Location:Clemson, SC
confused
I am running several Geeklog installations on one server, using the same domain. I have one site at sqrville.org, and one at projects.sqrville.org. I have been using them with no problems for quite some time. However I went to add another test site today, and now all the sites on subdomains won't allow me to login correctly.

I saw the FAQ entry about not being able to log in, and I've searched these forums a good bit on login, cookie and domain issues. I edited all my config.php's and gave them all unique cookie_name and cookie_url's. Still, the site at sqrville.org logs in alright, the others don't. For the main site I have cookie_url set to 'sqrville.org' instead of '.sqrville.org', though I have tried both. Do I need to come up with a subdomain and stick this main site on there or is there some other way of getting around this? Yes, I have cleared out all my cookies each time I changed settings around, and I also checked the after revisiting the sites to make sure the new cookies were being accepted and contained the updated info. Thanks, chris
 Quote

Status: offline

thelusiv

Forum User
Junior
Registered: 05/21/04
Posts: 23
Location:Clemson, SC
I've just realized that if I log out of the main site I can refresh the subdomain site and it will appear logged in. If I then log back in to the main site and refresh the subdomain site it will appear as if I'm not logged in. This occurs if the main site's cookie_url = 'sqrville.org' or '.sqrville.org'. I should probably also mention that all these sites are dyndns sites but I'm accessing them over the local network. Thanks, chris
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
The problem is that '.sqrville.org' will match every subdomain as well. So if you have a cookie for the main site, it would also match for all the sites on a subdomain.

Set $_CONF['cookiedomain'] to the full subdomain name for each subdomain site, e.g. '.example.sqrville.org' for http://example.sqrville.org (the extra dot is there so that it still works when people use 'www.example.sqrville.org').

For the main site, you could change $_CONF['cookiedomain'] to 'www.sqrville.org' - but that would mean that logins wouldn't work for http://sqrville.org any more (only for http://www.sqrville.org).

The other option is to leave it at '.sqrville.org' (for the main site only) and rename the cookies. If, for example, the session cookie would be named 'main_session' for the main site and 'gl_session' for all the subdomain sites, then the browser would still send the 'main_session' cookie to the subdomain site, but the subdomain site would ignore it and use the 'gl_session' cookie instead.

bye, Dirk
 Quote

Status: offline

thelusiv

Forum User
Junior
Registered: 05/21/04
Posts: 23
Location:Clemson, SC
Thanks! That fixed things right up. One more login question - I'm not sure if this is related to cookies or what, but every time I log into one of my Geeklog sites, it logs in properly, but then displays the same page (looks like it was cached by the browser) as before I logged in. Once I refresh, everything is fine. This isn't a really big deal but I'm tired of hitting refresh and I'm sure it confuses some of the people who come to my sites...
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
Quote by thelusiv: it logs in properly, but then displays the same page (looks like it was cached by the browser) as before I logged in. Once I refresh, everything is fine.

The actual login happens in users.php, but Geeklog will try to take you back to the URL you came from, so that you can continue from there only that now you're logged in.

Some browsers with more aggressive caching may not recognize that while it's the same URL as before, the actual content has now changed. So check the browser's settings for options regarding caching. It's also possible that your proxy (if you have one) is responsible for this.

If that doesn't help, you'll have to resort to server-side measures. Most Geeklog themes include a line
Text Formatted Code
<meta http-equiv="Pragma" content="no-cache">
 
in their header.thtml (although it's commented out in many themes). That, when activated, would instruct the browser not to cache things. However, that's a pretty drastic measure which can make your site slower to load (and increase your traffic).

Caching is a complex topic. I'd recommend reading up on it before you resort to server-side measures. Try this Caching Tutorial for starters.

bye, Dirk
 Quote

All times are EST. The time is now 08:57 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content