本文整理汇总了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());
}
}
示例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()));
}
}
示例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']);
}
}
示例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;
}
}
}
示例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;
}
示例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;
}
示例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();
}
示例8: __construct
protected function __construct()
{
//Initialize session object.
$this->Session = Session::getSession();
//Start page tracking utility.
$this->Tracker = Tracker::getTracker();
}
示例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();
}
示例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;
}
示例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']);
}
}
示例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;
}
示例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;
}
示例14: writeSessionAttribute
public function writeSessionAttribute($oTemplateIdentifier)
{
$sValue = Session::getSession()->getAttribute($oTemplateIdentifier->getValue());
if ($oTemplateIdentifier->hasParameter('reset')) {
Session::getSession()->resetAttribute($oTemplateIdentifier->getValue());
}
return $sValue;
}
示例15: actionStart
public function actionStart()
{
//получаем id игры
Session::getSession();
Yii::app()->session['loser'] = GameUtils::USER_LOSER;
//переходим на страницу с игрой
$this->redirect(array('gamestep/create'));
}