phpbb 3.1 passing variable between 2 pages

2019-06-04 03:44发布

With phpbb3.1 it appears they have disabled more superglobals. I have tried passing a variable between using sessions, but have had no success.

$_SESSION['example'] = 'example';
$example = $_SESSION['example'];

Nothing is stored because nothing is there due to phpbb disabling superglobals. What's the next best and most secure way to pass variables in between pages?

标签: php phpbb3
2条回答
Bombasti
2楼-- · 2019-06-04 04:34

I'm not sure if $_SESSION is included, but try phpBBs request class...

$example = $request->variable('example','');

Docs for the class are here - https://wiki.phpbb.com/PhpBB3.1/RFC/Request_class

查看更多
We Are One
3楼-- · 2019-06-04 04:37

You might want to take a look at this answer, where I explained that you can also temporarily (or globally) switch Superglobals back:

Globally

Open the /phpbb/config/parameters.yml file and change the core.disable_super_globals key from true to false.

Programmatically

This is a sample code that can be used to temporarily enable superglobals (per-request scope):

// temporarily enable superglobals
$request->enable_super_globals();

// TODO: do your stuff here.

// disable superglobals again
$request->disable_super_globals();

You can also read this blog post that I wrote on this topic for further info.

查看更多
登录 后发表回答