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


PHP Zend_Session::RememberMe方法代码示例

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


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

示例1: getLocale

 /**
  * Get the local. Logic depends on whether the given controller is marked
  * as 'urlLocale' or not.
  *
  * @param Context $ctx
  * @param Controller $controller
  * @param String $lang the language from the URL, or null if it's not there.
  * @return String locale (language)
  */
 private function getLocale($ctx, $controller, $lang)
 {
     // We only care here about controllers which are marked as 'urlLocale'
     if (!$controller->isLocaleSupported()) {
         return $ctx->getUser()->getLocale();
     }
     if (!$lang) {
         $lang = $ctx->getUser()->getLocale();
     }
     // Update anonymous user's locale, if it's different than the given lang
     if ($ctx->getUser()->isAnonymous() && $ctx->getUser()->getLocale() != $lang) {
         $ctx->getUser()->setLocale($lang);
         // TODO: does this code have to be here??
         Zend_Session::setOptions(array('cookie_httponly' => 'on'));
         Zend_Session::RememberMe(1209600);
         // 14 days
     }
     return $lang;
 }
开发者ID:fruition-sciences,项目名称:phpfw,代码行数:28,代码来源:Application.php

示例2: loginAction

 public function loginAction()
 {
     //if the user is logged already redir to home
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $this->_redirect('/' . $this->lang . '/woeid/' . $this->location . '/give');
     }
     $request = $this->getRequest();
     $form = $this->_getUserLoginForm();
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($request->getPost())) {
             $f = new Zend_Filter_StripTags();
             $email = $f->filter($this->_request->getPost('email'));
             $password = $f->filter($this->_request->getPost('password'));
             //DDBB validation
             // setup Zend_Auth adapter for a database table
             $readConf = new Zend_Config_Ini(APPLICATION_PATH . '/config/nolotiro.ini', 'production');
             $dbAdapter = Zend_Db::factory($readConf->resources->db);
             $authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter);
             $authAdapter->setTableName('users');
             $authAdapter->setIdentityColumn('email');
             $authAdapter->setCredentialColumn('password');
             // Set the input credential values to authenticate against
             $authAdapter->setIdentity($email);
             $authAdapter->setCredential(md5(trim($password)));
             //trim whitespaces from copy&pasting the pass from email
             // do the authentication
             $auth = Zend_Auth::getInstance();
             //check first if the user is activated (by confirmed email)
             $select = $authAdapter->getDbSelect();
             $select->where('active > 0');
             //check if the user is not locked (spammers, bad users, etc)
             $select->where('locked = 0');
             $result = $authAdapter->authenticate();
             if ($result->isValid()) {
                 // success: store database row to auth's storage
                 // system. (Not the password though!)
                 $data = $authAdapter->getResultRowObject(null, 'password');
                 $auth->getStorage()->write($data);
                 $woeid = $this->_helper->CheckWoeidUser->checkUserLogged($auth->getIdentity()->id);
                 $this->_helper->_flashMessenger->addMessage($this->view->translate('Welcome,') . ' ' . $auth->getIdentity()->username);
                 Zend_Session::start();
                 //check if user wants to be remembered by 7 days
                 $seconds = 60 * 60 * 24 * 7;
                 if ($this->_request->getPost('rememberme') == "1") {
                     Zend_Session::RememberMe($seconds);
                 } else {
                     Zend_Session::ForgetMe();
                 }
                 //check the redir value if setted
                 $aNamespace = new Zend_Session_Namespace('Nolotiro');
                 $redir = $aNamespace->redir;
                 if ($redir !== null) {
                     $aNamespace->redir = null;
                     //reset redir value
                     $this->_redirect($redir);
                 } else {
                     //if redir empty goto main home ads and set the welcome logged in message
                     $this->_redirect('/' . $this->lang . '/woeid/' . $woeid . '/give');
                 }
             } else {
                 // failure: wrong username
                 $view = $this->initView();
                 $view->error = $this->view->translate('Wrong email or password, please try again');
             }
         }
     }
     // assign the form to the view
     $this->view->form = $form;
 }
开发者ID:Arteaga2k,项目名称:nolotiro,代码行数:70,代码来源:AuthController.php


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