The MU forums have moved to WordPress.org

COOKIE_DOMAIN : Problem and why taking the site one? (3 posts)

  1. basszje
    Member
    Posted 17 years ago #

    Hi all,

    Maybe a little cryptic. This is my first post here although I use WPmu quite a long time now, so bear with me.

    In het newest installation there is this line in wp-settings.php :

    if ( !defined('COOKIE_DOMAIN') ) define('COOKIE_DOMAIN', '.' . $current_site->domain);

    In my setup there is WP_site, the table which contains 1 relevant record containing the TLD domain and /weblog/ as path. All my blogs are on subdomain.tld.nl/weblog/ and taken from the domain path in the wp_blogs table. This is also the one which is used site-wide to indentify the blog.

    Why does COOKIE-DOMAIN take the TLD var from the other table instead of the one used in blogs. This causes problems in Internet Explorer ( 'no cookies allowed' ) and sometimes in Firefox with 'hanging' cookies.

    To point out:

    if ( !defined('COOKIE_DOMAIN') ) define('COOKIE_DOMAIN', '.' . $current_site->domain);

    is trouble and:

    if ( !defined('COOKIE_DOMAIN') ) define('COOKIE_DOMAIN', '.' . $current_blog->domain);

    works like a charm as far I can see.

    So why is that? Are there any arguments for it or can this constant better be said to the Blog one?

    I hope it's clear what I'm trying to ask.

  2. sgrunt
    Member
    Posted 17 years ago #

    hi basszje, your code is very useful.
    Now i think it is an hard choice, and i try to resume:

    with your code, both in IE and Firefox:

    user or admin should log into every blog, and logout from every blog. If user logs into 1.blog he will not logged into 2.blog, and it is the same for logout

    with original code:

    in IE admin or user should log ONCE in the main blog and he will be logged in every sub blog. Log in or log out from sub blogs have no effects

    in Firefox (last version) it is a drama: user or admin can log into the main blog but i have no chance to log into subblogs, and so wordpressmu have no sense.

    I think to use your code, ok it is ugly to log in manually to every sub blog, but with default browser options i presume users should only make it at the first log, then cookies should mantain them logged. The problem it is the logout: users should logout from all the sub blogs!

  3. basszje
    Member
    Posted 17 years ago #

    Geesh you are right and I thought I was being smart, but didn't check this one. That's a dilemma indeed, hum.

    I've done some more testing, but I can't get behind the problem. At home I cannot reproduce the problem with Windows Firefox nor on Ubuntu. It's just that sometimes when the cookie domain is set wrong WPmu cannot change it anymore (security) thus creating a problem with logging in.

    My code is doing what you said in the post, but for now the orginal works like a charm now?

    Thanks for the feedback anyway. When I find something interesting I'll post it here of course.

    One thing is for sure: if there are cookies to .subdomain.domain.nl then .domain.nl cookies like in the orginal will fail until the cookies are cleared.

    -edit Still with the orginal stuff my Explorer version keeps on bugging ( version 6.0.2 ) and saying my browser doesn't accept any cookies. It's still a mystery to me why, could this be related to the 'test-cookie' case?

About this Topic