MyBB Community Forums

Full Version: Use cookies for other site pages
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I woudl like to implement the mybb login system on other ppages of my website..

How choult I retrieve the stored cookie information to continue the mybb sessions onto my other custom webpages,

I've already browsed the net like crazy on this one and could only get to this solution which obviously didn't work out for me  Undecided

<?php
    global $rootpath;
    $rootpath = "/share/Web/public_html/";

    $forumpath = $rootpath . "forums/";
    
    chdir($forumpath);
    define("IN_MYBB", 1);
    require($forumpath . "global.php");
    require_once MYBB_ROOT."inc/class_parser.php";
    $parser = new postParser;
    chdir($rootpath);
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>


<?php
    // Display if the user is logged in
    if ($mybb->user['uid']) {
?>
Welcome <a href="/forums/member.php?action=profile&uid=<?php echo $mybb->user["uid"]; ?>"><?php echo $mybb->user["username"]; ?></a>
<br />
<a href="/forums/member.php?action=logout&amp;<?php echo "logoutkey={$mybb->user['logoutkey']}"; ?>">Logout</a>
<?php
    } else { // If the user is not logged in then display the login form
?>
<form action="/forums/member.php" method="post">
    <input type="hidden" name="my_post_key" value="<?php echo $mybb->post_code; ?>" />
    Username: <input type="text" name="username" size="20" maxlength="30" /><br />
    Password: <input type="password" name="password" size="20" /><br />
    <input type="hidden" name="action" value="do_login" />
    <input type="hidden" name="url" value="/index.php" />
    <input type="submit" name="submit" value="Login" />
</form>
<?php
    }
?>


</body>
</html>