Forum / Development Forum / Feedback / Using $_SESSION 


+   Reply to Thread

Hello,

I am unable to use the following code:

{if="isset($_SESSION['is_admin']) && USER_TYPE == 1337"}
  | <a href="admin.php">Admin CP</a>
{/if}


Its says that "$_SESSION" is illegal, but I'm wondering.
Why disallow "$_SESSION" but you do allow "$_POST" in the script...

Let me know how to use those variables.

Thanks,
Alexw
_SESSION is disabled, and _POST should be as well.

A good solution is to use the method User::is_admin(), provided by the Rain Framework:
http://www.rainframework.com/User-Guide/Library/User/is_admin/
{if="is_admin()"} ... {/if}


Another good solution is to assign your variable:
$tpl->assign("is_admin", $_SESSION['is_admin'] );


Only if you really need to, you can remove _SESSION from the black list:
$black_list = array( '\$this', 'raintpl::', 'self::', '_SERVER', '_ENV', 'eval', 'exec', 'unlink', 'rmdir' );
raintpl::configure( "black_list", $black_list );

http://www.raintpl.com/Documentation/Documentation-for-PHP-developers/Methods/Configure/#black_list

Thanks

+   Reply to Thread