root cookie v1.2 (wordpress plugin)

line Tags: ,

I’ve been a bit slow, aja pointed out the fault a few days ago, but I’ve been a bit slow off the mark :(

Anyway, here’s the official announcement,

root cookie version 1.2

This version primarily fixed the logout issue, and yup, I’ve learnt by my mistakes it loads it gently too ;)

nick

 

10 Comments

  1. Jim Says:

    I was wondering, now that the cookie is based at the root domain, how do I access its information for usage?

  2. [NICK] Says:

    Try:

    print_r($_COOKIE);

    To view all cookies…. this might help too http://uk.php.net/setcookie :)

  3. Ian Says:

    Nick-

    I have a similar question to the one above, but may need a little more hand holding :(. I am currently running 7 WP 2.2 Blogs that all use the same Database. Users can register at any blog and be able to login to any of the other blogs with the same credentials.

    My issue is that when they navigate from blog to blog they are forced to login each time they visit it for the first time.

    What I would like is for their login to any one of the blogs to carry across all the blogs and I believe this is a cookie issue possibly solvable by your nifty plug-in.

    To try and clarify the site is http://www.theasianman.com. Each blog is in it’s own directory under the root i.e. the homepage is not a WP page but connects to each of the blogs.

    home: http://www.theasianman.com
    blog1: http://www.theasianman.com/wordpress
    blog2: http://www.theasianman.com/wordpress_sports

    and so on. Any help/advice would be much appreciated. (I would love to add a login on the home page as well if you have any tips on that)

    Cheers-
    Ian

  4. [NICK] Says:

    Hi Ian, I’m assuming you’ve tried rootCookie, and it failed, I know that the plugin will do part of the job, all cookies set by the plug-in will be available to the other sites but I’m sure I’ve seen that the cookie name is associate to the WP url… I guess you’ve already hacked WP so that each install uses the same table ?

  5. [NICK] Says:

    …done a quick google for you.. here’s the problem..


    $cookiehash = md5(get_option('siteurl'));
    define('COOKIEHASH', $cookiehash);
    ....
    define('USER_COOKIE', 'wordpressuser_'. COOKIEHASH);
    ....
    define('PASS_COOKIE', 'wordpresspass_'. COOKIEHASH);

    found from … http://svn.automattic.com/wordpress/trunk/wp-settings.php
    fix that & your’re away :D

  6. Ian Says:

    When you say fix that do you mean specifically define ’siteurl’ to something like

    $cookiehash = md5(get_option(’http://theasianman.com’));

    else:

    I’m not that php savvy so if I need to pass a variable between scripts I may need some pointers

    Thanks for your help

    I have not tried your Plug yet, could that be the quick and dirty work around?

  7. [NICK] Says:

    Hi Ian,
    As far as I can see you have a few hurdles to overcome.
    (1) You need to see if any hack you do can be plugged as when it comes to upgrade time you’re gonna have to go through each blog and re-apply any thing you change.
    (2) Hack/Plug each wordpress so that they share a user table… i.e. if someone changes their password they only have to do it once.
    (3) set $cookiehash = md5(get_option(’http://theasianman.com’) in all of the blogs.
    (4) install rootcookie plugin in all of the blogs to set the correct cookie permissions.

    I strongly recommend that you set yourself up a test box in vmware or something as any mistakes could lock you out of WP and make a whole heap of trouble.

  8. Ben Says:

    Hy there. I’m testing right now your interesting script on Wordpress 2.3 version. It’s seems to have some small problems - it’s ok on the root folder, but when i try to logout on other subfolders it keeps me logged in. :(

    I’m trying to do the same thing that Ian ask t you: use same cookies on multiple blogs - same domain. I’d followed all your steps, but i can’t make it work.

    Can you add an working example of wp-settings.php? if you have time. Thank you.

  9. Tim Says:

    I tried using this with wp 2.5.1, but had a bunch of errors when trying to log out (something to do with headers). I realize that on the wp plugin directory it notes that it is only compatible up to 2.1.2. There isn’t a chance that you will change it so that it works with 2.5.1?

    Of course I am assuming that it isn’t working and not a function of me missing some other requirement.

    Thanks.

  10. Nick Says:

    Hi Tim,
    Yeah you’re right, root-cookie probably doesn’t work on the WP2.5 series, I’ve read that the authentication back-end has changed a fair bit in 2.5, I’ll take a look to see what needs to be done to get this working again.
    cheers,
    Nick

Got something to say?

 

Some other things that might interest you...

---