En:Can I use PHP sessions in plugins?

From phpCMS

Jump to: navigation, search

Question: Can I use PHP sessions in plugins?

Answer:

Yes. But it is important that you have to use real globals, because phpCMS is running in a kind of sandbox, where a pseudo-global-scope is build.

Some code will make it easier to understand:

<?
session_start();
if (!isset($GLOBALS['phpcms_counter']))
{
session_register('phpcms_counter');
$GLOBALS['phpcms_counter']=1;
}
else
$GLOBALS['phpcms_counter']++;

$current = count($Tags);
$Tags[$current][0] = '<#counter#>';
$Tags[$current][1] = 'You have been here '.$GLOBALS['phpcms_counter'].' times!';
?>

Diese Seite in anderen Sprachen: Deutsch

Main Page: FAQ MainPage | Top Page: English FAQ MainPage

Personal tools