Php 如何使用会话
我需要使用session将这个id($invite=5000)存储在一个名为$fromid的变量中 我该怎么称呼这个呢Php 如何使用会话,php,joomla,joomla2.5,Php,Joomla,Joomla2.5,我需要使用session将这个id($invite=5000)存储在一个名为$fromid的变量中 我该怎么称呼这个呢 http://dev."xxxxxyyyyy".com/xxxxx-community/register.html?&invite=5000 另一个 class CommunityRegisterController extends CommunityBaseController { public function register() { } 您可以使用GE
http://dev."xxxxxyyyyy".com/xxxxx-community/register.html?&invite=5000
另一个
class CommunityRegisterController extends CommunityBaseController
{
public function register()
{
}
您可以使用GET方法获取值,然后将其存储在会话变量中, 例如:
register.php是表中存储用户所有详细信息的地方。因此,我可以在components/com_users/controllers/registration.php中使用它,因为它也是用户注册的地方。即管理员检查是否激活该特定配置文件。或者我应该将其存储在数据库中。
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;
}
class UsersControllerRegistration extends UsersController
{
}
$_SESSION['fromid'] = $_GET['invite'];
$fromid = $_SESSION['fromid'];