http://dev."xxxxxyyyyy".com/xxxxx-community/register.html?&invite=5000
我需要在一個名爲$ fromid使用session.There變量有兩個函數存儲此ID($邀請= 5000)在/components/com_community/controllers/register.php如何使用會話
我應該在哪裏調用這個以及如何?
class CommunityRegisterController extends CommunityBaseController
{
public function register()
{
}
另一個
public function register_save()
{
$mainframe =& JFactory::getApplication();
$modelRegister = CFactory::getModel('register');
// Check for request forgeries
$mySess =& JFactory::getSession();
if(! $mySess->has('JS_REG_TOKEN'))
{
echo '<div class="error-box">' . JText::_('COM_COMMUNITY_INVALID_SESSION') . '</div>';
return;
}
$token = $mySess->get('JS_REG_TOKEN','');
$ipAddress = isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
$authKey = $modelRegister->getAssignedAuthKey($token, $ipAddress);
$formToken = JRequest::getVar('authkey', '', 'REQUEST');
if(empty($formToken) || empty($authKey) || ($formToken != $authKey))
{
//echo $formToken .'|'. $authKey;
echo '<div class="error-box">' . JText::_('COM_COMMUNITY_INVALID_TOKEN') . '</div>';
return;
}
//update the auth key life span to another 180 sec.
$modelRegister->updateAuthKey ($token, $authKey, $ipAddress);
// Get required system objects
$config = CFactory::getConfig();
$post = JRequest::get('post');
// If user registration is not allowed, show 403 not authorized.
$usersConfig = &JComponentHelper::getParams('com_users');
if ($usersConfig->get('allowUserRegistration') == '0')
{
//show warning message
$view =& $this->getView('register');
$view->addWarning(JText::_('COM_COMMUNITY_REGISTRATION_DISABLED'));
echo $view->get('register');
return;
}
我可以訪問使用該類$ fromid在組件/ com_users /控制器/ registration.php的
class UsersControllerRegistration extends UsersController
{
}
http://www.phphelps.com/11_How_to_use_session.shtml – 2012-03-13 06:01:17