phpbb 3.1 passing variable between 2 pages

柔情痞子 提交于 2020-01-03 01:59:04

问题


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?


回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/35294795/phpbb-3-1-passing-variable-between-2-pages

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!