Share session between my site and wordpress blog

I would like to know how to share a session between my website non-wordpress and my wordpress blog on the same domain www.mysite.com, so that when a user is logged in to my site he’s also logged in to the blog

I installed wordpress as subdirectory on my site, url for my site is www.mysite.com and I access wordpress like this www.mysite.com/wordpressBlog

Read More

On my user_login.php in my main site I activated

session_start();

to activate cookies and on my wordpress wp_unregister_GLOBALS() I added

$no_unset = array( ‘_SESSION’, …

But nothing happen, when I login to my main site I still have to login to the blog

as a matter of fact my site and wordpress blog are on the same domain. I installed wordpress as subdirectory on my site url for my site is www.mysite.com and I access wordpress like this www.mysite.com/wordpressBlog On my user_login.php in my main site I activated

session_start();

to activate cookies and on my wordpress wp_unregister_GLOBALS() I added $no_unset = array( ‘_SESSION’, …

But nothing happen, when I login to my main site I still have to login to the blog

Related posts

Leave a Reply

1 comment

  1. In order to be able to share a session cookie between both sites, they will have to run under the same domain name (e.g. mysite.com). The following would be a valid configuration if the session cookie has a scope of mysite.com

    www.mysite.com
    blog.mysite.com
    

    PS. I don’t recommend using Cross Scripting hacks to get around this domain scoping issue. It’s limited to a domain for security reasons.

    [Edit]

    I should also point out that it is entirely valid to have your two sub-domains (sites) hosted on different servers

    [Edit]

    It is difficult to provide a succinct answer to your question because you are using a non-WP site. My best suggestion for you is to post on the WordPress StackExchange where you may get someone who has done this configuration before.

    I believe your issues are centred around the scope of your Cookie from WP. Editing your wp-config.php and setting the COOKIE_DOMAIN to use “” may help with your issue as referred to by this WordPress StackExchange post.

    Some posts speak of removing this settign entirely. In any case you need a way to debug your HTTP sessions to see what cookies are being sent using which scope, that is why I recommended FireBug. In any case you’re still going to have to re-code your non-WP site to recognise the WP cookies so understanding what’s going on is important.

    I did come across this other post regarding Multisite Domain Mapping that may help with your knowledge, but this is involved WP sites only so not exactly what you need.