MyBB Community Forums

Full Version: Custom pages in MyBB with secureCookieFlag
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
,Hi all,
I have a question regarding the custom pages. Usually I use the default template from MyBB docs for creating custom page i.e.

<?php

// Set some useful constants that the core may require or use
define("IN_MYBB", 1);
define('THIS_SCRIPT', 'my_plugin.php');

// Including global.php gives us access to a bunch of MyBB functions and variables
require_once "./global.php";

// Only required because we're using misc_help for our page wrapper
$lang->load("misc");

// Add a breadcrumb
add_breadcrumb('My Page', "my_plugin.php");

$hello_world = 'This text will appear on the page';
eval('$sections  = "' . $templates->get('hello_world_template') . '";');

// Using the misc_help template for the page wrapper
eval("\$page = \"".$templates->get("misc_help")."\";");

// Spit out the page to the user once we've put all the templates and vars together
output_page($page);

?>

Now I have observed something interesting,
- If I use the secureCookieFlag enabled, $mybb->user['uid'] is not identified
- If I disable secureCookieFlag, $mybb->user['uid'] is not identified
(Make sure to logout and Login after changing this setting)

My question - Is there anything missing in custom page template that should be there ?

Regards
WallBB
I don't see a reason why $mybb->user['uid'] is not available for you.
Try to print / echo $mybb->user['uid'] to be sure;
(2018-08-23, 06:59 PM)effone Wrote: [ -> ]I don't see a reason why $mybb->user['uid'] is not available for you.
Try to print / echo $mybb->user['uid'] to be sure;

Not working for me buddy, I did the same. Maybe something else I need to add in the php template ?
If global.php is included $mybb should be available.
Have you placed the file at root? Is the require path correct?
Are you getting any PHP error for file inclusion?

[Image: Untitled_1.png]
(2018-08-24, 05:48 AM)effone Wrote: [ -> ]If global.php is included $mybb should be available.
Have you placed the file at root? Is the require path correct?
Are you getting any PHP error for file inclusion?

[Image: Untitled_1.png]

All good buddy, exactly same thing I am doing. This is probably going to hurt my head a lot more to figure out what is going on. Anything else you think might be the reason ?
Not a place to do this, but we globalize variables to be available in plugins.
global $mybb;

If it is already declared you will get it.