Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Sep 2011
    Posts
    20
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Why do my phpBB sessions reset?

    I have a website in the root of my hosting package with my phpbb forum in the /forum directory.

    Here is the link to the site: http://www.alphakravmagainternational.com/index2.php

    Test the login with Username: testme , Pass: testme123

    I am attempting to establish a phpbb session on my website using the following codes:

    This code is included before the <HTML> of every page:

    Code:
    <?php
    define('IN_PHPBB', true);
    $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './forum/';
    $phpEx = substr(strrchr(__FILE__, '.'), 1);
    include($phpbb_root_path . 'common.' . $phpEx);
    
    // Start session management
    $user->session_begin();
    $auth->acl($user->data);
    $user->setup();
    
    // check for logout request
    $cp = $_GET['cp'];
    // is it a logout? then kill the session!
    if ($cp == "logout") {
    $user->session_kill();
    $user->session_begin();
    echo "Successfully Logged Out.";
    }
    ?>
    My login form in the header of every page:

    Code:
    <?php
    // Page login notice
    if ($user->data['user_id'] == ANONYMOUS)
    {
    ?>
    <img src="forum/images/avatars/gallery/noavatar.png" style="float:left; width:72px; height:72px;">
    <div class="login">
        <form method="POST" action="forum/ucp.php?mode=login">
        <ul><li><span>Username:</span> <input class="loginfield" type="text" name="username" size="20"></li>
            <li><span>Password:</span> <input class="loginfield" type="password" name="password" size="20"></li>
            <li>Remember Me? <input type="checkbox" name="autologin"> &nbsp; &nbsp; &nbsp; <a href="forum/ucp.php?mode=register">Register</a></li>
            <li><input type="submit" value="Login" name="login"></li>
        </ul>
        <input type="hidden" name="redirect" value="index.php">
        </form>
    </div>  
    
    <?php
    } else { ?>
    
    <img src="forum/images/avatars/gallery/<?php echo $user->data['user_avatar']; ?>" style="float:left; width:72px; height:72px;">
    <div class="login">
        Welcome back, <?php echo $user->data['username_clean']; ?><br> 
        You have <?php echo $user->data['user_unread_privmsg']; ?> new messages<br>
        <a href="index2.php?cp=logout">Log Out</a>
    </div>
    <?php } ?>
    It looks like I am able to log in, however, when I click to a different page the session is gone and I have to log in again. This happens when I click to the forum as well. I cant for the life of me figure this out and It's driving me crazy. Please help!

    Thank you for reading.

  • #2
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,322
    Thanks
    60
    Thanked 525 Times in 512 Posts
    Blog Entries
    4
    Phpbb is a very large and complex program. You won't get detailed support for it here however their own forums WILL be able to help you - goto their website and then register on their own forums and repost your question. No-one here will know phpbb in depth enough to help you I'm afraid.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •