Search code examples
phpsessionphpbb

phpbb session across folders


I'm using a phpBB (2.0.22) in a website, located at myWebSite.com/forum

I am creating some other pages in myWebSite.com/otherForders

What I want, is to check whether a person in logged into myWebSite.com/forum when they are in myWebSite.com/otherForders

Wondering if that's possible.

I've tried session_start(); print_r($_SESSION); in myWebSite.com/otherForders/index.php and all I get is Array ( ) (an empty array).

Anyone with a solution? Thanks.


Solution

  • You should integrate your board with your code

    Here is sample ::

    define('IN_PHPBB', true);
    $phpbb_root_path = './';
    include($phpbb_root_path . 'extension.inc');
    include($phpbb_root_path . 'common.'.$phpEx);
    
    //
    // Start session management
    //
    $userdata = session_pagestart($user_ip, PAGE_INDEX);
    init_userprefs($userdata);
    //
    // End session management
    //
    

    Then use

    $userdata['username'], $userdata['user_id'] & etc. $userdata has array with values from users_table for your board for logged in user.