当前位置: 首页>>代码示例>>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方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: login

 /**
  * This method logs in the user
  * Member login
  * @author Kashif Irshad
  * @param string $userName
  * @param string $password in md5 encryption
  * @return string return 'success' for successfully login and all other messages are error message 
  */
 public function login($userName, $password, $remember)
 {
     $userTable = new Application_Model_DbTable_User();
     $authAdapter = new Zend_Auth_Adapter_DbTable(Zend_Db_Table::getDefaultAdapter());
     $authAdapter->setTableName('users');
     $authAdapter->setIdentityColumn('username');
     $authAdapter->setCredentialColumn('password');
     $authAdapter->setIdentity($userName);
     $authAdapter->setCredential($password);
     $authAdapter->setAmbiguityIdentity(true);
     $auth = Zend_Auth::getInstance();
     $auth->setStorage(new Zend_Auth_Storage_Session('user'));
     $result = $auth->authenticate($authAdapter);
     if ($result->isValid()) {
         if ($remember > 0) {
             $oneMinute = 60;
             $oneHour = $oneMinute * 60;
             $oneDay = $oneHour * 24;
             $oneWeek = $oneDay * 7;
             $oneMonth = $oneDay * 30;
             Zend_Session::rememberMe($oneWeek);
         }
         return 'success';
     } else {
         $userRow = $userTable->fetchRow("username='{$userName}'");
         if (isset($userRow)) {
             return 'Invalid password';
         } else {
             return 'Invalid username or password';
         }
     }
 }
开发者ID:Genius-Outsourcing-Pvt-Ltd,项目名称:pathology,代码行数:40,代码来源:User.php

示例2: loginAction

 public function loginAction()
 {
     $form = new Form_AuthLogin();
     $form->setAction($this->_helper->url($this->getRequest()->getActionName()));
     $auth = $this->getHelper('Auth')->getAuth();
     if (!$auth->hasIdentity()) {
         if ($this->getRequest()->isPost()) {
             if ($form->isValid($this->getRequest()->getPost())) {
                 $auth = $this->getHelper('Auth')->getAuth();
                 $authAdapter = new Model_Auth_Adapter_User($form->getValue('username'), $form->getValue('password'));
                 $result = $auth->authenticate($authAdapter);
                 if ($result->isValid()) {
                     if ($form->getValue('rememberMe')) {
                         // can configure in config
                         // use resources.session.remember_me_seconds
                         Zend_Session::rememberMe();
                     }
                     $this->_redirect('/');
                 } else {
                     $form->addErrorMessage('authError');
                 }
             }
         }
         $this->view->form = $form;
     }
 }
开发者ID:kandy,项目名称:HamsterCMF,代码行数:26,代码来源:AuthController.php

示例3: indexAction

 public function indexAction()
 {
     $this->view->login = false;
     // проверка не залогинен ли пользователь
     if (!Zend_Auth::getInstance()->getIdentity()) {
         // берем форму логина и закидываем во view
         $form = $this->_getLoginForm();
         $this->view->form = $form;
         // если форма была отправлена, мы должны еЄ проверить
         if ($this->_request->isPost()) {
             $formData = $this->_request->getPost();
             // провер¤ем форму
             if ($form->isValid($formData)) {
                 // провер¤ем входные данные
                 $result = $this->_authenticate($form->getValue('realm'), $form->getValue('username'), $form->getValue('password'));
                 if ($result->isValid()) {
                     // запомним пользовател¤ на 2 недели
                     if ($form->getValue('rememberMe')) {
                         Zend_Session::rememberMe(60 * 60 * 24 * 14);
                     }
                     // отправл¤ем на главную
                     $this->_redirect('/');
                 } else {
                     // failure: выводим сообщение о ошибке
                     $this->view->error = 'Authorization error. Please check login or/and password';
                 }
             } else {
                 $form->populate($formData);
             }
         }
     } else {
         $this->view->login = true;
         $this->view->username = Zend_Auth::getInstance()->getIdentity();
     }
 }
开发者ID:TDMU,项目名称:contingent5_statserver,代码行数:35,代码来源:LoginController.php

示例4: loginAction

 public function loginAction()
 {
     $this->_form = new Mybase_Form_Login();
     if (!$this->getRequest()->isPost()) {
         $this->view->form = $this->_form;
     } else {
         $form = $this->_form;
         if (!$form->isValid($_POST)) {
             $this->view->form = $form;
             $this->_flash('Všechna pole musí být vyplněna', 'error', false);
         } else {
             $values = $form->getValues();
             $auth = Zend_Auth::getInstance();
             $authAdapter = new Zend_Auth_Adapter_DbTable(Zend_Db_Table_Abstract::getDefaultAdapter(), 'user_login', 'username', 'password', 'MD5(?)');
             $modelAccount = new Model_Account();
             $idaccount = $modelAccount->getId($this->_request->account);
             $select = $authAdapter->getDbSelect();
             $select->where('idaccount = ' . $idaccount);
             $authAdapter->setIdentity($values['username']);
             $authAdapter->setCredential($values['password']);
             $result = $auth->authenticate($authAdapter);
             switch ($result->getCode()) {
                 case Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND:
                     $this->view->form = $form;
                     $this->_flash('Špatné uživatelské jméno', 'error', false);
                     break;
                 case Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID:
                     $this->view->form = $form;
                     $this->_flash('Špatné heslo', 'error', false);
                     break;
                 case Zend_Auth_Result::SUCCESS:
                     $storage = $auth->getStorage();
                     $storage->write($authAdapter->getResultRowObject(array('email', 'name', 'surname', 'username', 'iduser', 'owner', 'administrator')));
                     if ($form->getValue('remember') == 1) {
                         Zend_Session::rememberMe(60 * 60 * 24 * 14);
                     }
                     //$this->_redirect('http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']);
                     $this->_redirect('/');
                     break;
                 case Zend_Auth_Result::FAILURE:
                     $this->view->form = $form;
                     $this->_flash('Neznámá chyba (FAILURE)', 'error', false);
                     break;
                 case Zend_Auth_Result::FAILURE_IDENTITY_AMBIGUOUS:
                     $this->view->form = $form;
                     $this->_flash('"Nejednoznačné"', 'error', false);
                     break;
                 case Zend_Auth_Result::FAILURE_UNCATEGORIZED:
                     $this->view->form = $form;
                     $this->_flash('Neznámá chyba(FAILURE_UNCATEGORIZED)', 'error', false);
                     break;
                 default:
                     $this->view->form = $form;
                     $this->_flash('Neznámá chyba (default)', 'error', false);
                     break;
             }
         }
     }
     $this->_helper->layout->disableLayout();
 }
开发者ID:besters,项目名称:My-Base,代码行数:60,代码来源:AuthController.php

示例5: _checkAccount

 /**
  * check if email or password exists in database
  * @param array post data
  */
 protected function _checkAccount($post)
 {
     $login = new User_Model_Login();
     $loginStatus = array();
     $emailStatus = false;
     $passwordStatus = false;
     $adapter = $this->_getAuthAdapter();
     $adapter->setIdentity($post['user-email'])->setCredential($post['password']);
     require_once APPLICATION_PATH . '/../library/Zend/Auth.php';
     $auth = Zend_auth::getInstance();
     $result = $auth->authenticate($adapter);
     if ($result->isValid()) {
         //login successful
         Zend_Session::start();
         $user = $adapter->getResultRowObject();
         $auth->getStorage()->write($user);
         $user_session = new Zend_Session_Namespace('Zend_Auth');
         $user_session->email = Zend_Auth::getInstance()->getStorage()->read()->email;
         Zend_Session::rememberMe();
         $this->redirect('index/index');
     } else {
         if ($result->getCode() == Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND) {
             $this->view->loginStatus = '帳號不存在';
         } else {
             if ($result->getCode() == Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID) {
                 $this->view->loginStatus = '密碼錯誤';
             } else {
                 $this->view->loginStatus = '請重新登入';
             }
         }
     }
 }
开发者ID:ChenYoyo,项目名称:NLC-Event-Platform,代码行数:36,代码来源:LoginController.php

示例6: loginAction

 /**
  * Perform login against OneLogin API
  */
 public function loginAction()
 {
     // Clear identity before logging in
     if (Zend_Auth::getInstance()->hasIdentity()) {
         Zend_Auth::getInstance()->clearIdentity();
         Zend_Session::destroy(true);
     }
     // Proceed to logging in
     if ($this->_request->isPost()) {
         $username = $this->_request->getPost('username');
         $password = $this->_request->getPost('password');
         try {
             // create instance
             $login = new OneLogin_Acl_Login();
             $login->login($username, $password);
             $expirationTime = 60 * 60 * 8;
             // 8 hours
             Zend_Session::rememberMe($expirationTime);
             $this->_helper->layout->enableLayout();
             return $this->_helper->redirector('ol', 'index', 'users');
         } catch (Exception $e) {
             //print_r($e);
             $msg = $e->getMessage();
             $this->view->message = $msg;
             $this->render('index');
         }
     } else {
         $this->_forward("index");
     }
 }
开发者ID:juliomolinero,项目名称:onelogin-api-php,代码行数:33,代码来源:IndexController.php

示例7: loginAction

 public function loginAction()
 {
     $loginForm = new Form_Login();
     $resetForm = new Form_ResetPassword();
     $request = $this->getRequest();
     if ($request->isPost()) {
         $loginForm->isValid($request->getPost());
         $adapter = new Infra_AuthAdapter($request->getPost('email'), $request->getPost('password'), $request->getPost('timezone_offset'));
         //$adapter = new Zend_Auth_Adapter_DbTable($zendDb);
         $auth = Infra_AuthHelper::getAuthInstance();
         $result = $auth->authenticate($adapter);
         if ($result->isValid()) {
             // Zend_Session::getSaveHandler()->write(uniqid(), $result->getIdentity());
             if ($request->getPost('remember_me')) {
                 Zend_Session::rememberMe(60 * 60 * 24 * 7);
             }
             // 1 week
             $nextUri = $this->_getParam('next_uri');
             KalturaLog::debug("next uri {$nextUri}");
             if ($nextUri && strlen($nextUri) > 1) {
                 $this->_helper->redirector->gotoUrl($nextUri);
             } else {
                 $this->_helper->redirector('list-by-user', 'partner');
             }
         } else {
             $loginForm->setDescription('invalid login');
         }
     }
     $loginForm->setDefault('next_uri', $this->_getParam('next_uri'));
     // set in Infra_AuthPlugin
     $this->view->loginForm = $loginForm;
     $this->view->resetForm = $resetForm;
     $this->render('login');
 }
开发者ID:EfncoPlugins,项目名称:Media-Management-based-on-Kaltura,代码行数:34,代码来源:UserController.php

示例8: signIn

 public static function signIn($userName, $password, $rememberMe = false, $md5 = true)
 {
     $retVal = false;
     // set ZendX_Doctrine_Auth_Adapter
     $auth = Zend_Auth::getInstance();
     $authAdapter = new ZendX_Doctrine_Auth_Adapter(Doctrine::getConnectionByTableName('Model_Entity_User'));
     $password = $md5 ? md5($password) : $password;
     $authAdapter->setTableName('Model_Entity_User u')->setIdentityColumn('userName')->setCredentialColumn('password')->setCredentialTreatment('? AND active = 1')->setIdentity($userName)->setCredential($password);
     // set Zend_Auth
     $result = $auth->authenticate($authAdapter);
     // Check Auth Validation
     if ($result->isValid()) {
         // Remove some fields which are secure!
         $omitColumns = array('password', 'activationKey', 'created_at', 'updated_at', 'deleted_at', 'created_by', 'updated_by');
         $identity = $authAdapter->getResultRowObject(null, $omitColumns);
         $identity->roles = Kebab_Model_User::getUserRoles($identity->id);
         $identity->acl = new Kebab_Access_Acl();
         $identity->stories = Kebab_Model_Story::getUserStoriesName($identity->roles);
         $auth->getStorage()->write($identity);
         if ($rememberMe) {
             Zend_Session::rememberMe(604800);
         }
         $retVal = true;
     }
     return $retVal;
 }
开发者ID:esironal,项目名称:kebab-project,代码行数:26,代码来源:Authentication.php

示例9: loginAction

 public function loginAction()
 {
     $loginForm = new Form_Login();
     $resetForm = new Form_ResetPassword();
     $request = $this->getRequest();
     if ($request->isPost()) {
         $adapter = new Kaltura_AuthAdapter($request->getPost('email'), $request->getPost('password'));
         $auth = Zend_Auth::getInstance();
         $result = $auth->authenticate($adapter);
         if ($result->isValid()) {
             if ($request->getPost('remember_me')) {
                 Zend_Session::rememberMe(60 * 60 * 24 * 7);
             }
             // 1 week
             $nextUri = $this->_getParam('next_uri');
             if ($nextUri) {
                 $this->_helper->redirector->gotoUrl($nextUri);
             } else {
                 $this->_helper->redirector('list', 'partner');
             }
         } else {
             $loginForm->setDescription('login error');
         }
     }
     $loginForm->setDefault('next_uri', $this->_getParam('next_uri'));
     // set in Kaltura_AuthPlugin
     $this->view->loginForm = $loginForm;
     $this->view->resetForm = $resetForm;
     $this->render('login');
 }
开发者ID:richhl,项目名称:kalturaCE,代码行数:30,代码来源:UserController.php

示例10: indexAction

 public function indexAction()
 {
     $registry = Zend_Registry::getInstance();
     $auth = Zend_Auth::getInstance();
     $config = $registry->get("config");
     $sessionConfig = $config['resources']['session'];
     Ml_Model_AntiAttack::loadRules();
     $credential = Ml_Model_Credential::getInstance();
     $logger = Ml_Model_Logger::getInstance();
     if ($auth->hasIdentity()) {
         return $this->_forward("goback");
     }
     $request = $this->getRequest();
     $form = $credential->loginForm();
     if (Ml_Model_AntiAttack::ensureHuman()) {
         $ensureHuman = true;
     } else {
         $ensureHuman = false;
     }
     if ($request->isPost()) {
         ignore_user_abort(true);
         //A way to sign in only if captcha is right. This is a workaround to
         //signout if the captcha is wrong.
         //
         //I've decided to put the sign in code in the validator itself,
         //but couldn't find a way to make the password validator
         //load after the captcha one (but to let it come first in code,
         //and that's ugly on the screen) and get a result if the
         //validation worked. Notice that it is only useful when
         //the captcha is required.
         if ($form->isValid($request->getPost())) {
             //@see below
             $session = Ml_Model_Session::getInstance();
             //rememberMe and ForgetMe already regenerates the ID
             if ($form->getElement("remember_me")->isChecked()) {
                 Zend_Session::rememberMe($sessionConfig['cookie_lifetime']);
             } else {
                 Zend_Session::ForgetMe();
             }
             $session->associate($auth->getIdentity(), Zend_Session::getId());
             $logger->log(array("action" => "login", "username" => $form->getValue("username")));
             $this->_forward("goback");
         } else {
             //@see above
             if ($auth->hasIdentity()) {
                 $auth->clearIdentity();
             }
             $logger->log(array("action" => "login_denied", "username" => $form->getValue("username")));
             $this->view->errorlogin = true;
         }
         //@end of workaround
     }
     $challenge = $form->getElement("challenge");
     //don't show missing value in the first time that asks for the captcha
     if (!$ensureHuman && is_object($challenge)) {
         $challenge->setErrorMessages(array("missingValue" => ''));
     }
     $this->view->loginform = $form;
 }
开发者ID:henvic,项目名称:MediaLab,代码行数:59,代码来源:LoginController.php

示例11: loginAction

    public function loginAction()
    {
        // Don't allow logged in people here
        $user = Zend_Auth::getInstance()->getIdentity();
        if ($user !== null) {
            $this->_redirect('/');
        }

        $this->view->title = 'Log in';
        if ($this->_request->isPost()) {
            // collect the data from the user
            $f = new Zend_Filter_StripTags();
            $username = $f->filter($this->_request->getPost('handle'));
            $password = $f->filter($this->_request->getPost('password'));

            if (empty($username) || empty($password)) {
                $this->addErrorMessage('Please provide a username and password.');
            } else {
                // do the authentication
                $authAdapter = $this->_getAuthAdapter($username, $password);
                $auth   = Zend_Auth::getInstance();
                $result = $auth->authenticate($authAdapter);

                if ($result->isValid()) {
                    $auth->getStorage()->write($authAdapter->getResult());

                    // Receive Zend_Session_Namespace object
                    $session = new Zend_Session_Namespace('Zend_Auth');
                    // Set the time of user logged in
                    $session->setExpirationSeconds(24*3600);

                    // If "remember" was marked
                    if ($this->getRequest()->getParam('rememberme') !== null) {
                        // remember the session for 604800s = 7 days
                        Zend_Session::rememberMe(604800);
                    }

                    $ns = new Zend_Session_Namespace('lastUrl');
                    $lastUrl = $ns->value;
                    if ($lastUrl !== '') {
                        $ns->value = '';

                        // If our last request was an tester ajax request just
                        // go back to /tester
                        $lastUrl = (strpos($lastUrl,'/tester/ajax') === false) ? $lastUrl : '/tester';

                        $this->_redirect($lastUrl);
                    }

                    $this->_redirect('/');
                } else {
                    // failure: clear database row from session
                    $this->addErrorMessage('Login failed.');
                }
            }
        } else {
            $this->getResponse()->setHeader('HTTP/1.1', '403 Forbidden');
        }
    }
开发者ID:reith2004,项目名称:frapi,代码行数:59,代码来源:AuthController.php

示例12: kloginAction

 /**
  * Login user
  *
  */
 public function kloginAction()
 {
     $this->_helper->getHelper('viewRenderer')->setNoRender();
     $this->_helper->getHelper('layout')->disableLayout();
     $response = array();
     $request = $this->getRequest();
     /**
      * Redirect to dashboard if user has logged in already
      */
     if ($request->isPost()) {
         $username = $request->getPost('u');
         $password = $request->getPost('p');
         $remember = $request->getPost('s');
         $authMan = new Pandamp_Auth_Manager($username, $password);
         $authResult = $authMan->authenticate();
         $zendAuth = Zend_Auth::getInstance();
         if ($zendAuth->hasIdentity()) {
             if ($authResult->isValid()) {
                 $returnUrl = base64_decode($request->getPost('r'));
                 if (!empty($returnUrl)) {
                     if (strpos($returnUrl, '?')) {
                         $sAddition = '&';
                     } else {
                         $sAddition = '?';
                     }
                     $data = array('success' => true, 'msg' => 'Logging in', 'message' => "{$returnUrl}" . $sAddition . "PHPSESSID=" . Zend_Session::getId());
                     Pandamp_Lib_Formater::writeLog();
                     // to help thwart session fixation/hijacking
                     // @modifiedDate 2014-09-15 17:01
                     if (isset($remember) && $remember == 'yes') {
                         /*$hol = new Pandamp_Core_Hol_Auth();
                         		$hol->user = $username;
                         		$hol->user_pw = $password;
                         		$hol->save_login = $remember;
                         		$hol->login_saver();*/
                         // remember the session for 604800s = 7 days
                         Zend_Session::rememberMe(604800);
                     } else {
                         // do not remember the session
                         // Zend_Session::forgetMe();
                     }
                     $this->_helper->FlashMessenger('Successful authentication');
                 }
             } else {
                 if ($authResult->getCode() != -51) {
                     Zend_Auth::getInstance()->clearIdentity();
                 }
                 $messages = $authResult->getMessages();
                 $data = array('error' => $messages[0], 'success' => false);
             }
         } else {
             $messages = $authResult->getMessages();
             $data = array('error' => $messages[0], 'failure' => true);
         }
     }
     $this->getResponse()->setBody(Zend_Json::encode($data));
 }
开发者ID:hukumonline,项目名称:admin,代码行数:61,代码来源:AccountController.php

示例13: loginAction

 public function loginAction()
 {
     $this->view->translate()->setLocale(isset($_GET['locale']) ? $_GET['locale'] : 'ru');
     $this->view->resource = $this->_request->getParam('resource');
     $this->view->headTitle($this->view->translate('Login page'));
     $this->view->headLink()->appendStylesheet(array('rel' => 'shortcut icon', 'type' => 'image/x-icon', 'href' => '/img/favicon.ico'));
     $this->view->headLink()->appendStylesheet('/modules/auth/css/login.css');
     if ($this->_request->isPost()) {
         //			file_put_contents('d:\\temp\\auth.txt', var_export($this->_request->getParams(), true));
         $filter = new Zend_Filter_StripTags();
         $username = $filter->filter($this->_request->getParam('username'));
         $password = $filter->filter($this->_request->getParam('password'));
         $woredir = $this->_request->getParam('woredir');
         if ($woredir) {
             $this->getHelper('viewRenderer')->setNoRender();
             $this->getHelper('layout')->disableLayout();
         }
         if (empty($username)) {
             $this->_response->setHttpResponseCode(401);
             // Unauthorized
             if ($woredir) {
                 echo 'Please, provide a username.';
             } else {
                 $this->view->message = 'Please, provide a username.';
             }
             //$this->view->translate('Please provide a username.');
         } else {
             Zend_Session::start();
             if (Uman_Auth::login($username, $password)) {
                 Zend_Session::rememberMe();
                 $auth = Zend_Auth::getInstance();
                 $identity = $auth->getIdentity();
                 $ns = new Zend_Session_Namespace('acl');
                 $ns->acl = new Uman_Acl($identity->NODEID, $identity->PATH);
                 if ($woredir) {
                     echo 'OK';
                 } else {
                     $this->_redirect($this->_request->getParam('resource', '/'));
                 }
             } else {
                 $this->_response->setHttpResponseCode(401);
                 // Unauthorized
                 Zend_Session::destroy();
                 if ($woredir) {
                     echo 'Authorization error. Please, try again.';
                 } else {
                     $this->view->message = $this->view->translate('Authorization error. Please, try again.');
                 }
             }
         }
     } else {
         if (Zend_Session::sessionExists()) {
             Zend_Session::start();
             Zend_Session::destroy();
         }
     }
 }
开发者ID:TDMU,项目名称:contingent5_statserver,代码行数:57,代码来源:PageController.php

示例14: _user2Login

 protected function _user2Login()
 {
     // php array to object
     $data = (object) ($arr = array('id' => 1001, 'login' => 'user2', 'role_id' => 2, 'role_name' => 'operator_role'));
     // write session
     $auth = Zend_Auth::getInstance();
     $storage = $auth->getStorage();
     $storage->write($data);
     Zend_Session::rememberMe();
     echo ' (login as ' . $data->login . ') ';
 }
开发者ID:neverstoplwy,项目名称:contrib-webacula,代码行数:11,代码来源:ControllerTestCase.php

示例15: login

 /**
  * Login user
  *
  * @param array $data
  * @return bool
  */
 public function login($data)
 {
     if ($this->authenticate($data['login'], $data['password'])) {
         $user = $this->getDbTable()->getByLogin($data['login']);
         $user->login();
         if (!empty($data['rememberMe'])) {
             Zend_Session::rememberMe(60 * 60 * 24 * 14);
         }
         return true;
     }
     return false;
 }
开发者ID:uglide,项目名称:zfcore-transition,代码行数:18,代码来源:Manager.php


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