-1

I'm trying to make phpbb a part of my current page, but I have run into a problem. When ever i redirect my user to a different site $user->data gets reset, and i can't seem to figure out why.

<?php
define('IN_PHPBB', true);
$phpbb_root_path = 'forum/';
$phpEx = "php";
include($phpbb_root_path . 'config.' . $phpEx);
include($phpbb_root_path . 'common.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();

if(isset($_GET["p"]) && $_GET["p"]=="login"){
    $result=$auth->login("username", "123456");

    if ($result['status'] == LOGIN_SUCCESS) {

        echo "You're logged in";

        header("location: test.php?p=test");

    } else {

        echo $user->lang[$result['error_msg']];

    }

}

if(isset($_GET["p"]) && $_GET["p"]=="test"){
    $user->session_begin();
    $auth->acl($user->data);
    $user->setup();
    if($user->data['is_registered']){
        echo "logged in!";
    }
    else{
        echo "not logged in!";
    }
}
?>
nickknissen
  • 253
  • 2
  • 7
  • 1
    If you redirect to a different _site_, then `$user->data` (which is presumably based on a session) will reflect the session for that site. I would guess that it is unset or null if there is no session for that site. – halfer Apr 19 '12 at 20:01
  • sorry for being unclear, but what i meant was page not site. The sessions gets destroyed when a redirect to a different page. The test page i have in my code says "not logged in!". – nickknissen Apr 20 '12 at 10:45
  • 1
    Please correct your question, then. Check your cookie settings in your browser to ensure you're accepting them, and ensure that the page you are traversing to also starts a session in the correct way for this system. Monitor your sessions using something like Firebug, so you can see if it is the browser or the server that are 'forgetting' them. – halfer Apr 20 '12 at 10:47
  • (I'll undownvote when the question is fixed, please ping me here i.e. @halfer). – halfer Apr 20 '12 at 10:48

2 Answers2

0

Found the solution, i'm running this local and was using a different cookie domain. So the solution was just to update the cookie domain in phpbb settings

nickknissen
  • 253
  • 2
  • 7
0

I am also working on a similar project and for me it worked by just saving the user data in a $_SESSION and then just on every page to have

session_start();
Tunaki
  • 132,869
  • 46
  • 340
  • 423
John_Dean
  • 37
  • 7