sharing session with wordpress

I currently have a website that has wordpress installed within a subfolder of the website, e.g. http://example.com/wordpress/. In example.com i have some session veriables set that i’d also like to make available in wordpress. I’ve read that wordpress doesn’t support sessions and clears sessions by default but i’ve googled about and found the following solution:

in load.php stop function wp_unregister_GLOBALS() unestting _SESSION

Read More
$no_unset = array( '_SESSION', ....

In functions.php (of the theme) add the session start when wordpress initialises:

if ( !session_id() )
add_action( 'init', 'session_start' );

This all works great. I can set a session in wordpress and it remains throughout the wordpress site. What isn’t working is i’m losing my session variables between my main site and when i navigate within the wordpress folder. Does anyone know how i can retain the session i created in the main site within my worpress blog?

Thanks

Related posts

1 comment

  1. I thinks the reason is that:

    example.com have a cookie like “php_session” to keep the status of session
    example.com/wordpress/ have another cookie like “wordpress_session” too keep itself session.

    you should make a same name between the two program.

    session_name('session_id') maybe help you.

Comments are closed.