Support » Fixing WordPress » Create WordPress Sessions from CakePHP

Viewing 1 replies (of 1 total)
  • I am a complete CakePHP n00b, but I’ll try and reply to you as best I can.

    First, what you need is shared authentication. You either need to modify WordPress to get its username and password data from CakePHP’s tables, or modify your Cake app to gets its username/password data from WordPress.

    Both should be doable. I know WordPress has a file called wp-includes/pluggable.php. All the functions in there can be replaced by a plugin. Some of the functions in pluggable.php are related to logging in, so you could possibly hack WordPress to fetch its user data from your Cake tables that way.

    Once you have the user tables shared, you still have the issue of needing to log in twice. Making the user logged in to WordPress should be as simple as setting the right cookies with the right password hashes inside them.

    After logging into my WordPress site, I have four cookies:

    • wordpress_
    • wordpress_
    • wordpress_logged_in_
    • wordpress_test_cookie

    I am not sure why they have underscores after them — perhaps it is because I am running WordPress MU.

    Anyway, the content of the first three cookies looks something like this:


    So, basically, it has the username, and what is most likely a salted hash of the password.

    I don’t know how to calculate that hash, but once you manage to do it, setting the cookie from within your CakePHP application should be as simple as calling the setcookie function.

    I’m not sure if CakePHP has a “proper” way of setting cookies, and even if it does, it would probably not allow you to set the cookies with the right names to suit WordPress.

    Once the cookies are set, you should be correctly logged in to WordPress.

    If anybody here knows any better how WordPress’ login cookies are set, your feedback is most welcome.

    Neohunter, I hope I have been a help, and if not, please let me know why. 🙂

Viewing 1 replies (of 1 total)
  • The topic ‘Create WordPress Sessions from CakePHP’ is closed to new replies.