本文整理汇总了PHP中Zend_Session_Namespace::setExpirationSeconds方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Session_Namespace::setExpirationSeconds方法的具体用法?PHP Zend_Session_Namespace::setExpirationSeconds怎么用?PHP Zend_Session_Namespace::setExpirationSeconds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Session_Namespace
的用法示例。
在下文中一共展示了Zend_Session_Namespace::setExpirationSeconds方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public function init()
{
//set timeout
$this->_sessionAdmin = new Zend_Session_Namespace(Zend_Auth_Storage_Session::NAMESPACE_DEFAULT);
$this->_sessionAdmin->setExpirationSeconds(30 * 60);
//load acl
$aclLoader = HCMS_Acl_Loader::getInstance();
$aclLoader->load();
if (!Zend_Auth::getInstance()->hasIdentity()) {
$this->_admin = null;
} else {
$this->_admin = Zend_Auth::getInstance()->getIdentity();
$aclLoader->setCurrentRoleCode($aclLoader->getRoleCode($this->_admin->get_role_id()));
}
$this->view->admin = $this->_admin;
if ($this->_checkAuth) {
$this->_checkAuthorization();
}
$this->_redirect_to_ssl();
$this->_checkIP();
//set ACL object for Zend_Navigation
Zend_View_Helper_Navigation_HelperAbstract::setDefaultAcl($aclLoader->getAcl());
Zend_View_Helper_Navigation_HelperAbstract::setDefaultRole($aclLoader->getCurrentRoleCode());
$this->_initVersionInfo();
$this->_module = new Application_Model_Module();
if (Application_Model_ModuleMapper::getInstance()->findByCode($this->getRequest()->getModuleName(), $this->_module)) {
$this->view->moduleSettings = $this->_module->get_settings();
}
parent::init();
}
示例2: __construct
/**
* Constructor, set optionnaly custom expiration seconds
*
* @param int $expirationSeconds
* @return void
*/
public function __construct($namespace = 'Zfx_Registry_Session', $expirationSeconds = 1800)
{
self::$_namespace = $namespace;
self::$_session = new Zend_Session_Namespace($namespace);
self::$_session->setExpirationSeconds($expirationSeconds);
self::$_session->lock();
}
示例3: __construct
/**
* Constructor
*
* @param string $sessionId
*/
public function __construct($sessionId)
{
// session storage
$this->_session = new \Zend_Session_Namespace(__CLASS__ . $sessionId);
$this->_session->setExpirationSeconds($this->_expiration);
// 3 hours
}
示例4: _initSession
public function _initSession()
{
Zend_Session::start();
$defaultNameSpace = new Zend_Session_Namespace("defaultsession");
$defaultNameSpace->setExpirationSeconds(7200);
Zend_Registry::set("defaultsession", $defaultNameSpace);
}
示例5: loginAction
public function loginAction()
{
try {
$this->_helper->layout->disableLayout();
$request = $this->getRequest();
$sessionNamespace = new Zend_Session_Namespace();
if ($sessionNamespace->loginAuth == true) {
$this->_helper->redirector('index', 'index', 'gyuser');
}
if ($this->getRequest()->isPost()) {
$mapper = new Gyuser_Model_OperatorDataMapper();
$Obj = new Gyuser_Model_Operator();
if ($request->user_name) {
$Obj->setEmail($request->user_name);
}
if ($request->password) {
$Obj->setPassword($request->password);
}
$result = $mapper->LoginAuth($Obj);
if ($result->getId()) {
$sessionNamespace = new Zend_Session_Namespace();
$sessionNamespace->loginAuth = true;
$sessionNamespace->authDetail = $result;
$sessionNamespace->setExpirationSeconds(7 * 24 * 60 * 60, 'a');
$this->_helper->redirector('dashboard', 'index', 'gyuser');
} else {
$this->view->invalid = true;
}
}
} catch (Exception $e) {
echo $e;
}
}
示例6: logarAction
public function logarAction()
{
$this->_helper->viewRenderer->setNoRender(true);
$this->_helper->layout()->disableLayout();
$resposta = array();
$dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
$authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter);
$authAdapter->setTableName('sca_usuario')->setIdentityColumn('login_usuario')->setCredentialColumn('password_usuario')->getDbSelect()->join(array('g' => 'sca_grupo'), 'g.id_grupo = sca_usuario.id_grupo', array('nm_grupo', 'is_root'));
$authAdapter->setIdentity($this->getRequest()->getParam('login_usuario'))->setCredential($this->getRequest()->getParam('password_usuario'))->setCredentialTreatment('MD5(?) and st_usuario = 1');
//Realiza autenticacao
$result = $authAdapter->authenticate();
//Verifica se a autenticacao foi validada
if ($result->isValid()) {
//obtem os dados do usuario
$usuario = $authAdapter->getResultRowObject();
//Armazena seus dados na sessao
$storage = Zend_Auth::getInstance()->getStorage();
$storage->write($usuario);
// se não for para lembrar os dados expira a sessao em 30 minutos
if (!$this->getRequest()->getParam('lembrar')) {
$session = new Zend_Session_Namespace('Zend_Auth');
$session->setExpirationSeconds(1800);
}
//Redireciona para o Index
$resposta['situacao'] = "success";
$resposta['msg'] = "Logando aguarde...";
} else {
$resposta['situacao'] = "error";
$resposta['msg'] = "Usuário inativo ou senha incorreta.";
}
echo json_encode($resposta);
}
示例7: loginAction
public function loginAction()
{
if (!$this->getRequest()->isPost()) {
return $this->_forward('index');
}
$form = $this->getForm();
if (!$form->isValid($_POST)) {
// Falla la validación; Se vuelve a mostrar el formulario
$this->view->form = $form;
return $this->render('form');
}
$username = $form->getValue('username');
$password = $form->getValue('password');
$remember = $form->getValue('remember');
$usuario = new Application_Model_Usuario();
$result = $usuario->validarLogin($username, $password);
if (!$result->isValid()) {
// Autenticación fallida, imprime el porque
return $this->_redirect('/');
} else {
$usuario->setIdUsuario($result->getIdentity());
$mysession = new Zend_Session_Namespace('sesion');
$mysession->actividad = 'SI';
$mysession->setExpirationSeconds(60 * 5, 'actividad');
//$mysession->usuario_id = $usuario->getIdUsuario();
$mysession->usuario_nombre = $result->getIdentity();
$_SESSION['username'] = strtoupper($mysession->usuario_nombre);
$aux = $usuario->getUsuariobyNombreUsuario($mysession->usuario_nombre);
$mysession->usuario_id = $aux[0]['iUsuIdUsuario'];
$mysession->tipo_usuario = $aux[0]['TipoUsuario_iTiUsuarioIdTipoUsuario'];
$log = new Application_Model_Logs();
$log->crearLog('A');
$this->redireccionar();
}
}
示例8: _initSes
/**
* Initialize session
*/
protected function _initSes()
{
$ses = new \Zend_Session_Namespace(self::SESSION_NAMESPACE, true);
$ses->setExpirationHops(5, null, true);
$ses->setExpirationSeconds(60 * 60 * 24);
$this->_ses = $ses;
}
示例9: submitAction
/**
* When the user actually submits their otp, this authenticates it.
*/
public function submitAction()
{
$this->disableLayout();
$this->disableView();
Zend_Session::start();
$mfaSession = new Zend_Session_Namespace('Mfa_Temp_User');
$user = $mfaSession->Dao;
if (!isset($user) || !$user) {
echo JsonComponent::encode(array('status' => 'error', 'message' => 'Session has expired, refresh and try again'));
return;
}
$otpDevice = $this->Mfa_Otpdevice->getByUser($user);
if (!$otpDevice) {
throw new Zend_Exception('User does not have an OTP device');
}
$token = $this->getParam('token');
try {
$valid = $this->ModuleComponent->Otp->authenticate($otpDevice, $token);
} catch (Zend_Exception $exc) {
$this->getLogger()->crit($exc->getMessage());
echo JsonComponent::encode(array('status' => 'error', 'message' => $exc->getMessage()));
return;
}
if ($valid) {
session_start();
$authUser = new Zend_Session_Namespace('Auth_User');
$authUser->setExpirationSeconds(60 * Zend_Registry::get('configGlobal')->session->lifetime);
$authUser->Dao = $user;
$authUser->lock();
$this->getLogger()->debug(__METHOD__ . ' Log in : ' . $user->getFullName());
echo JsonComponent::encode(array('status' => 'ok'));
} else {
echo JsonComponent::encode(array('status' => 'error', 'message' => 'Incorrect token'));
}
}
示例10: routeShutdown
public function routeShutdown(Zend_Controller_Request_Abstract $request)
{
$params = $request->getParams();
$auth = Zend_Auth::getInstance();
Zend_Registry::set('Zend_Auth', $auth);
if ($auth->hasIdentity()) {
$view = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('view');
$identity = $auth->getIdentity();
$userDb = new Users_Model_DbTable_User();
$user = array('id' => $identity->id, 'username' => $identity->username, 'name' => $identity->name, 'email' => $identity->email, 'clientid' => $identity->clientid);
$authNamespace = new Zend_Session_Namespace('Zend_Auth');
$authNamespace->user = $user['username'];
if ($_SESSION['__ZF']['Zend_Auth']['ENT'] - time() < 3600) {
$authNamespace->setExpirationSeconds(3600);
}
Zend_Registry::set('User', $user);
$view->user = $user;
$clientDb = new Application_Model_DbTable_Client();
$client = $clientDb->getClient($user['clientid']);
Zend_Registry::set('Client', $client);
} elseif ($params['module'] != 'users' && $params['action'] != 'login') {
$redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
if (isset($params['id']) && $params['id']) {
$redirector->gotoSimple('login', 'user', 'users', array('url' => $params['module'] . '|' . $params['controller'] . '|' . $params['action'] . '|' . $params['id']));
} else {
$redirector->gotoSimple('login', 'user', 'users', array('url' => $params['module'] . '|' . $params['controller'] . '|' . $params['action']));
}
}
}
示例11: init
public function init()
{
$langNamespace = new Zend_Session_Namespace('Lang');
$config = Zend_Registry::get('config');
if ($langNamespace->lang == null) {
//$config = Zend_Registry::get('config');
$defaultLanguage = strval($config->framework->language->default);
$langNamespace->lang = $defaultLanguage;
}
$this->view->home = $config->app->home;
$this->view->joomlahome = $config->joomla->home;
if (Zend_Auth::getInstance()->hasIdentity()) {
$authNamespace = new Zend_Session_Namespace('Zend_Auth');
$this->_currentUser = $authNamespace->user;
//2011-04-08 ham.bao separate the sessions with admin
$this->_currentAdmin = $authNamespace->admin;
$this->_currentClient = $authNamespace->client;
$this->view->currentUser = $this->_currentUser;
$authNamespace->setExpirationSeconds(12 * 60 * 60);
}
$this->_flashMessenger = $this->_helper->getHelper('FlashMessenger');
$ajaxContext = $this->_helper->getHelper('AjaxContext');
$ajaxContext->addActionContext('adminajax', 'json')->initContext();
$this->initView();
}
示例12: autenticacao
protected function autenticacao($isAjax = false)
{
if (!Zend_Auth::getInstance()->hasIdentity()) {
if ($isAjax) {
// if is ajax request, let js handle redirect properly ;)
$session = new Zend_Session_Namespace();
if (isset($session->url)) {
unset($session->url);
}
$this->view->error = _("Permission denied.");
$this->_response->setHttpResponseCode(403);
return false;
} else {
$session = new Zend_Session_Namespace();
$session->setExpirationSeconds(60 * 60 * 1);
// 1 minuto
$session->url = $_SERVER['REQUEST_URI'];
return $this->_helper->redirector->goToRoute(array(), 'login', true);
}
}
$sessao = Zend_Auth::getInstance()->getIdentity();
if (!$sessao["administrador"]) {
if ($this->getRequest()->isXmlHttpRequest()) {
$this->view->error = _("Unauthorized.");
$this->_response->setHttpResponseCode(401);
return false;
} else {
return $this->_helper->redirector->goToRoute(array('controller' => 'participante', 'action' => 'index'), 'default', true);
}
}
return true;
}
示例13: indexAction
public function indexAction()
{
$this->view->headTitle("uiwiki-登陆");
if ($this->getRequest()->isPost()) {
Zend_Loader::loadClass('Zend_Filter_StripTags');
$filter = new Zend_Filter_StripTags();
//表单的post值
$name = $filter->filter($this->_request->getPost('name'));
$password = $filter->filter($this->_request->getPost('password'));
if (!empty($name)) {
$authAdapter = new Zend_Auth_Adapter_DbTable();
$authAdapter->setTableName('ui_project')->setIdentityColumn('name')->setCredentialColumn('password')->setIdentity($name)->setCredential($password);
$auth = Zend_Auth::getInstance();
$result = $auth->authenticate($authAdapter);
// 执行认证查询,并保存结果
if ($result->isValid()) {
$data = $authAdapter->getResultRowObject(array('name', 'id'));
if ($auth->hasIdentity()) {
//auth之后写入session
$user = new Zend_Session_Namespace('user');
$user->name = $data->name;
$user->id = $data->id;
$user->setExpirationSeconds(6000);
//命名空间 "user" 将在第一次访问后 6000 秒过期
//echo '<h3><font color=red> 登录成功!</font></h3>';
$this->_redirect('/' . $name);
}
} else {
echo '<h3><font color=red> 登录失败,请重新登录!</font></h3>';
}
}
}
}
示例14: init
public function init()
{
$this->verificarInactividad();
$mysession = new Zend_Session_Namespace('sesion');
$mysession->setExpirationSeconds(60 * 3, 'actividad');
/* Initialize action controller here */
}
示例15: 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');
}
}