当前位置: 首页>>代码示例>>PHP>>正文


PHP Session::getSession方法代码示例

本文整理汇总了PHP中Session::getSession方法的典型用法代码示例。如果您正苦于以下问题:PHP Session::getSession方法的具体用法?PHP Session::getSession怎么用?PHP Session::getSession使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Session的用法示例。


在下文中一共展示了Session::getSession方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createSSOTokenFromRequest

 /**
  * Creates a single sign on token for the <code>HttpRequest</code>
  *
  * @param request <code>HttpServletRequest</code>
  * @return single sign on token for the request
  * @exception SSOException if the single sign on token cannot be created.
  */
 public function createSSOTokenFromRequest(array $request)
 {
     try {
         $sid = new SessionID($request);
         $session = Session::getSession($sid);
         if ($sid != null) {
             $cookieMode = $sid->getCookieMode();
             //                if (debug.messageEnabled()) {
             //                    debug.message("cookieMode is :" + cookieMode);
             //                }
             if ($cookieMode != null) {
                 $session->setCookieMode($cookieMode);
             }
         }
         if ($this->checkIP && !isIPValid($session, $_SERVER['REMOTE_ADDR'])) {
             throw new Exception("Invalid IP address");
         }
         $ssoToken = new SSOTokenImpl($session);
         return $ssoToken;
     } catch (Exception $e) {
         //            if (debug.messageEnabled()) {
         //                debug.message("could not create SSOToken from HttpRequest", e);
         //            }
         throw new SSOException($e->getMessage());
     }
 }
开发者ID:GajendraNaidu,项目名称:openam,代码行数:33,代码来源:SSOProviderImpl.php

示例2: deleteRow

 public function deleteRow($aRowData, $oCriteria)
 {
     $oLanguage = LanguagePeer::doSelectOne($oCriteria);
     if ($oLanguage->getIsDefault()) {
         throw new LocalizedException('wns.language.delete_default.denied');
     }
     if ($oLanguage->getIsDefaultEdit()) {
         throw new LocalizedException('wns.language.delete_default.denied');
     }
     if (LanguagePeer::doCount(new Criteria()) < 2) {
         throw new LocalizedException('wns.language.delete_last.denied');
     }
     $sLanguageId = $oLanguage->getId();
     foreach (LanguageObjectQuery::create()->filterByLanguageId($sLanguageId)->find() as $oLanguageObject) {
         $oHistory = $oLanguageObject->newHistory();
         $oHistory->save();
         $oLanguageObject->delete();
     }
     $iResult = $oLanguage->delete();
     $oReplacementLanguage = LanguageQuery::create()->findOne();
     if (AdminManager::getContentLanguage() === $sLanguageId) {
         AdminManager::setContentLanguage(Settings::getSetting("session_default", AdminManager::CONTENT_LANGUAGE_SESSION_KEY, $oReplacementLanguage->getId()));
     }
     if (Session::language() === $sLanguageId) {
         Session::getSession()->setLanguage(Settings::getSetting("session_default", Session::SESSION_LANGUAGE_KEY, $oReplacementLanguage->getId()));
     }
 }
开发者ID:rapila,项目名称:cms-base,代码行数:27,代码来源:LanguageListWidgetModule.php

示例3: view

 public function view()
 {
     config::set('heading', 'БЛОГ');
     $params = $this->getParams();
     if (isset($params[0])) {
         $alias = strtolower($params[0]);
         $this->data['one_blog'] = $this->model->getOneBlogWithComment($alias);
     }
     if ($_POST and isset($_POST['id_comm'])) {
         if (clearData($_POST['id_comm'])) {
             $id = clearData($_POST['id_comm']);
         } else {
             throw new Exception('Введены некорректные данные');
         }
         if (clearData($_POST['text-comm'])) {
             $text = clearData($_POST['text-comm'], true);
         } else {
             throw new Exception('Введены некорректные данные');
         }
         if (clearData($_POST['n_comm'])) {
             $name = clearData($_POST['n_comm']);
         } else {
             throw new Exception('Введены некорректные данные');
         }
         $tableUserId = Session::getSession('id') ? Session::getSession('id') : NULL;
         $this->model->addComment($id, $text, $name, $tableUserId);
         Router::redirect($_SERVER['REQUEST_URI']);
     }
 }
开发者ID:seletskyy,项目名称:blog_mvc,代码行数:29,代码来源:blogs.controller.php

示例4: defaultAction

 function defaultAction()
 {
     if (is_null(Session::getSession('user'))) {
         // On renvoit l'URL suivi de login, le Router redirigera sur le ControllerLogin
         // Comme on envoit pas d'action, l'actionDefault sera utilisée.
         die(header('Location:/login'));
     } else {
         // si on est là, un user est connecté,  il sagit maintenant de le diriger en fonction du Profil
         $O_user = Session::getSession('user');
         $S_profile = $O_user->getProfile()->getName();
         switch ($S_profile) {
             case 'admin':
                 //echo 'Vous avez le profil : ' . $S_profile;
                 die(header('Location:/user/paginate/1'));
                 break;
             case 'operator':
                 die(header('Location:/epi/userlist/' . $O_user->getOperatorId()));
                 // echo 'Vous avez le profil : ' . $S_profile;
                 break;
             default:
                 die(header('Location:/epi/tonextcheck/'));
                 break;
         }
     }
 }
开发者ID:Vincent-Troccaz,项目名称:safety,代码行数:25,代码来源:ControllerDefault.php

示例5: renderFrontend

 public function renderFrontend()
 {
     $oCriteria = DocumentQuery::create()->filterByDocumentKind('image');
     if (!Session::getSession()->isAuthenticated()) {
         $oCriteria->filterByIsProtected(false);
     }
     if ($this->iCategoryId !== null) {
         $oCriteria->filterByDocumentCategoryId($this->iCategoryId);
     }
     $aDocuments = $oCriteria->find();
     $sTemplateName = 'helpers/gallery';
     try {
         $oListTemplate = new Template($sTemplateName);
         foreach ($aDocuments as $i => $oDocument) {
             $oItemTemplate = new Template($sTemplateName . DocumentListFrontendModule::LIST_ITEM_POSTFIX);
             $oItemTemplate->replaceIdentifier('model', 'Document');
             $oItemTemplate->replaceIdentifier('counter', $i + 1);
             $oDocument->renderListItem($oItemTemplate);
             $oListTemplate->replaceIdentifierMultiple('items', $oItemTemplate);
         }
     } catch (Exception $e) {
         $oListTemplate = new Template("", null, true);
     }
     return $oListTemplate;
 }
开发者ID:rapila,项目名称:cms-full,代码行数:25,代码来源:CategorySubpagesFrontendModule.php

示例6: saveData

 public function saveData($aSubscriberGroupData)
 {
     if ($this->iSubscriberGroupId) {
         $oSubscriberGroup = SubscriberGroupQuery::create()->findPk($this->iSubscriberGroupId);
     } else {
         $oSubscriberGroup = new SubscriberGroup();
         $oSubscriberGroup->setCreatedBy(Session::getSession()->getUserId());
         $oSubscriberGroup->setCreatedAt(date('c'));
     }
     $oSubscriberGroup->setName($aSubscriberGroupData['name']);
     $oSubscriberGroup->setDisplayName($aSubscriberGroupData['display_name'] == null ? null : $aSubscriberGroupData['display_name']);
     $this->validate($aSubscriberGroupData);
     if (!Flash::noErrors()) {
         throw new ValidationException();
     }
     $oSubscriberGroup->save();
     $oResult = new stdClass();
     $oResult->id = $oSubscriberGroup->getId();
     if ($this->iSubscriberGroupId === null) {
         $oResult->inserted = true;
     } else {
         $oResult->updated = true;
     }
     $this->iSubscriberGroupId = $oResult->id;
     return $oResult;
 }
开发者ID:rapila,项目名称:plugin-newsletter,代码行数:26,代码来源:SubscriberGroupDetailWidgetModule.php

示例7: run

 public static function run($uri)
 {
     self::$router = new Router($uri);
     self::$db = new DB(config::get('db.host'), config::get('db.name'), config::get('db.user'), config::get('db.password'));
     Lang::load(self::$router->getLanguage());
     if ($_POST and (isset($_POST['username_in']) and isset($_POST['password_in'])) or isset($_POST['exit'])) {
         $us = new RegisterController();
         if (isset($_POST['exit'])) {
             $us->LogOut();
         } else {
             $us->Login($_POST);
         }
     }
     if (self::$router->getController() == 'admin' and !Session::getSession('root') or self::$router->getController() == 'myblog' and !Session::getSession('id')) {
         self::$router->setController(Config::get('default_controller'));
         self::$router->setAction(Config::get('default_action'));
         Session::setSession('message', 'Отказ в доступе');
     }
     $controller_class = ucfirst(self::$router->getController()) . 'Controller';
     $controller_method = strtolower(self::$router->getMethodPrefix() . self::$router->getAction());
     $controller_object = new $controller_class();
     if (method_exists($controller_object, $controller_method)) {
         $controller_object->{$controller_method}();
         $view_object = new View($controller_object->getData());
         $content = $view_object->render();
     } else {
         throw new Exception('Method ' . $controller_method . ' of class ' . $controller_class . ' does not exist');
     }
     $layout = self::$router->getRoute();
     $layout_path = VIEWS_PATH . DS . $layout . '.html';
     $layout_view_object = new View(compact('content'), $layout_path);
     echo $layout_view_object->render();
 }
开发者ID:seletskyy,项目名称:blog_mvc,代码行数:33,代码来源:app.class.php

示例8: __construct

 protected function __construct()
 {
     //Initialize session object.
     $this->Session = Session::getSession();
     //Start page tracking utility.
     $this->Tracker = Tracker::getTracker();
 }
开发者ID:Vidarious,项目名称:Curator_OLD,代码行数:7,代码来源:Curator.php

示例9: saveData

 public function saveData($aSubscriberData)
 {
     $oSubscriber = SubscriberQuery::create()->findPk($this->iSubscriberId);
     if ($oSubscriber === null) {
         $oSubscriber = new Subscriber();
         $oSubscriber->setCreatedBy(Session::getSession()->getUserId());
         $oSubscriber->setCreatedAt(date('c'));
     }
     $oSubscriber->setPreferredLanguageId($aSubscriberData['preferred_language_id']);
     $oSubscriber->setName($aSubscriberData['name']);
     $oSubscriber->setEmail($aSubscriberData['email']);
     $this->validate($aSubscriberData, $oSubscriber);
     if (!Flash::noErrors()) {
         throw new ValidationException();
     }
     // Subscriptions
     foreach ($oSubscriber->getSubscriberGroupMemberships() as $oSubscriberGroupMembership) {
         $oSubscriberGroupMembership->delete();
     }
     $aSubscriptions = isset($aSubscriberData['subscriber_group_ids']) ? $aSubscriberData['subscriber_group_ids'] : array();
     foreach ($aSubscriptions as $iSubscriberGroupId) {
         $oSubscriberGroupMembership = new SubscriberGroupMembership();
         $oSubscriberGroupMembership->setSubscriberGroupId($iSubscriberGroupId);
         $oSubscriber->addSubscriberGroupMembership($oSubscriberGroupMembership);
     }
     return $oSubscriber->save();
 }
开发者ID:rapila,项目名称:plugin-newsletter,代码行数:27,代码来源:SubscriberDetailWidgetModule.php

示例10: renderFrontend

 /**
  * The render method for the login page type. When on a login page type, this is given the login action as determined by the page type. Can be either null (default), 'password_forgotten', or 'password_reset' (or any other string of which a template "$sLoginType_action_$sAction" exists).
  *
  */
 public function renderFrontend($sAction = 'login')
 {
     $aOptions = @unserialize($this->getData());
     $sLoginType = isset($aOptions[self::MODE_SELECT_KEY]) ? $aOptions[self::MODE_SELECT_KEY] : 'login';
     $this->oUser = Session::getSession()->getUser();
     if ($this->oUser) {
         $sAction = 'logout';
     }
     $oTemplate = $this->constructTemplate($sLoginType);
     if ($oTemplate->hasIdentifier('function_template')) {
         $oFunctionTemplate = null;
         try {
             $oFunctionTemplate = $this->constructTemplate("{$sLoginType}_action_{$sAction}");
         } catch (Exception $e) {
             //Fallback to the default function template for the specified action
             $oFunctionTemplate = $this->constructTemplate("login_action_{$sAction}");
         }
         $oTemplate->replaceIdentifier('function_template', $oFunctionTemplate, null, Template::LEAVE_IDENTIFIERS);
     }
     if ($this->oUser && $this->oPage) {
         $oPage = $this->oPage;
         if (Session::getSession()->hasAttribute('login_referrer_page')) {
             $oPage = Session::getSession()->getAttribute('login_referrer_page');
             Session::getSession()->resetAttribute('login_referrer_page');
         }
         if (!$this->oPage->getIsProtected() || Session::getSession()->getUser()->mayViewPage($this->oPage)) {
             $oTemplate->replaceIdentifier('fullname', Session::getSession()->getUser()->getFullName());
             $oTemplate->replaceIdentifier('name', Session::getSession()->getUser()->getUsername());
             $oTemplate->replaceIdentifier('action', LinkUtil::link(FrontendManager::$CURRENT_NAVIGATION_ITEM->getLink(), null, array('logout' => 'true')));
         } else {
             $oFlash = Flash::getFlash();
             $oFlash->addMessage('login.logged_in_no_access');
         }
     }
     $oTemplate->replaceIdentifier('login_title', TranslationPeer::getString($sAction == 'password_forgotten' ? 'wns.login.password_reset' : 'wns.login'));
     $sOrigin = isset($_REQUEST['origin']) ? $_REQUEST['origin'] : LinkUtil::linkToSelf();
     $oTemplate->replaceIdentifier('origin', $sOrigin);
     if ($sAction !== 'logout') {
         $oLoginPage = $this->oPage ? $this->oPage->getLoginPage() : null;
         $sLink = null;
         if ($oLoginPage === null) {
             $sLink = LinkUtil::link('', 'LoginManager');
         } else {
             $sLink = LinkUtil::link($oLoginPage->getFullPathArray());
         }
         $oTemplate->replaceIdentifier('action', $sLink);
     }
     if ($sAction === 'login') {
         $oLoginPage = $this->oPage ? $this->oPage->getLoginPage() : null;
         $sLink = null;
         if ($oLoginPage === null) {
             $sLink = LinkUtil::link(array(), 'LoginManager', array('password_forgotten' => 'true'));
         } else {
             $sLink = LinkUtil::link($oLoginPage->getFullPathArray(), null, array('password_forgotten' => 'true'));
         }
         $oTemplate->replaceIdentifier('password_forgotten_action', $sLink);
     }
     return $oTemplate;
 }
开发者ID:rapila,项目名称:cms-base,代码行数:63,代码来源:LoginFrontendModule.php

示例11: __construct

 public function __construct(Page $oPage = null, NavigationItem $oNavigationItem = null, $sLanguageId = null)
 {
     parent::__construct($oPage, $oNavigationItem, $sLanguageId);
     $this->sAction = 'login';
     if (isset($_REQUEST['origin']) && !Session::getSession()->hasAttribute('login_referrer')) {
         Session::getSession()->setAttribute('login_referrer', $_REQUEST['origin']);
     }
 }
开发者ID:rapila,项目名称:cms-base,代码行数:8,代码来源:LoginPageTypeModule.php

示例12: propertiesFromPage

 private static function propertiesFromPage($oPage)
 {
     $oUser = Session::getSession()->getUser();
     $aResult = $oPage->toArray();
     $aResult['UserMayCreateChildren'] = $oUser->mayCreateChildren($oPage);
     $aResult['UserMayCreateSiblings'] = $oPage->getParent() !== null && $oUser->mayCreateChildren($oPage->getParent());
     return $aResult;
 }
开发者ID:rapila,项目名称:cms-base,代码行数:8,代码来源:PagesAdminModule.php

示例13: getCriteria

 public function getCriteria()
 {
     $oQuery = DocumentCategoryQuery::create();
     if (!Session::getSession()->getUser()->getIsAdmin() || Settings::getSetting('admin', 'hide_externally_managed_document_categories', true)) {
         return $oQuery->filterByIsExternallyManaged('false');
     }
     return $oQuery;
 }
开发者ID:rapila,项目名称:cms-base,代码行数:8,代码来源:DocumentsAdminModule.php

示例14: writeSessionAttribute

 public function writeSessionAttribute($oTemplateIdentifier)
 {
     $sValue = Session::getSession()->getAttribute($oTemplateIdentifier->getValue());
     if ($oTemplateIdentifier->hasParameter('reset')) {
         Session::getSession()->resetAttribute($oTemplateIdentifier->getValue());
     }
     return $sValue;
 }
开发者ID:rapila,项目名称:cms-base,代码行数:8,代码来源:SpecialTemplateIdentifierActions.php

示例15: actionStart

 public function actionStart()
 {
     //получаем id игры
     Session::getSession();
     Yii::app()->session['loser'] = GameUtils::USER_LOSER;
     //переходим на страницу с игрой
     $this->redirect(array('gamestep/create'));
 }
开发者ID:tatyanayavkina,项目名称:yii_city_game,代码行数:8,代码来源:GameController.php


注:本文中的Session::getSession方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。