pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

    • <bdo id='gm7oo'></bdo><ul id='gm7oo'></ul>
    <legend id='gm7oo'><style id='gm7oo'><dir id='gm7oo'><q id='gm7oo'></q></dir></style></legend>

      <small id='gm7oo'></small><noframes id='gm7oo'>

    1. <i id='gm7oo'><tr id='gm7oo'><dt id='gm7oo'><q id='gm7oo'><span id='gm7oo'><b id='gm7oo'><form id='gm7oo'><ins id='gm7oo'></ins><ul id='gm7oo'></ul><sub id='gm7oo'></sub></form><legend id='gm7oo'></legend><bdo id='gm7oo'><pre id='gm7oo'><center id='gm7oo'></center></pre></bdo></b><th id='gm7oo'></th></span></q></dt></tr></i><div class="zzvz3ln" id='gm7oo'><tfoot id='gm7oo'></tfoot><dl id='gm7oo'><fieldset id='gm7oo'></fieldset></dl></div>
    2. <tfoot id='gm7oo'></tfoot>

      Zend Framework 不活動后自動注銷

      Zend Framework Automatic Logout after inactivity(Zend Framework 不活動后自動注銷)

      <legend id='02UdU'><style id='02UdU'><dir id='02UdU'><q id='02UdU'></q></dir></style></legend>

            <tfoot id='02UdU'></tfoot>

            <small id='02UdU'></small><noframes id='02UdU'>

            <i id='02UdU'><tr id='02UdU'><dt id='02UdU'><q id='02UdU'><span id='02UdU'><b id='02UdU'><form id='02UdU'><ins id='02UdU'></ins><ul id='02UdU'></ul><sub id='02UdU'></sub></form><legend id='02UdU'></legend><bdo id='02UdU'><pre id='02UdU'><center id='02UdU'></center></pre></bdo></b><th id='02UdU'></th></span></q></dt></tr></i><div class="lhdzlb1" id='02UdU'><tfoot id='02UdU'></tfoot><dl id='02UdU'><fieldset id='02UdU'></fieldset></dl></div>

              <bdo id='02UdU'></bdo><ul id='02UdU'></ul>
                  <tbody id='02UdU'></tbody>
                本文介紹了Zend Framework 不活動后自動注銷的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我正在開發一個包含多個子應用程序的應用程序,我想在 30 分鐘不活動后實現自動注銷.我有一個使用 Bootstrap.php 映射到自定義/login 和/logout 路由的登錄和注銷操作的 AuthController 以及如下所示的前端控制器插件:

                I'm working on an application that houses several sub applications and I'd like to implement an auto logout after 30 minutes of inactivity. I have an AuthController with login and logout actions mapped to custom /login and /logout routes using the Bootstrap.php as well as a front controller plugin that looks like this:

                class Plugin_SessionTrack extends Zend_Controller_Plugin_Abstract {
                
                    public function preDispatch(Zend_Controller_Request_Abstract $request)
                    {  
                
                        $employeeSession = new Zend_Session_Namespace('employeeSession');
                        $employeeSession->setExpirationSeconds(10);
                
                    }
                }
                

                我是 PHP 和 Zend 的新手,10 秒后會話到底發生了什么?我將它設置為低以進行測試.我希望發生的是,如果通過前端控制器插件的最后一個請求的時間大于 30 分鐘前,則銷毀會話并注銷用戶并將其重定向到/login.

                I'm new to PHP and Zend, what exactly is happening to the session after 10 seconds? I have it set low for testing. What I'd like to have happen is if the time of the last request through the front controller plugin was greater than 30 minutes ago, destroy the session and log the user out and redirect them to /login.

                我可以清楚地看到我沒有跟蹤上次請求的時間,但我希望每次用戶通過這個 preDispatch 方法收到請求時都會刷新 setExpirationSeconds.

                I can see obviously that I'm not tracking the time of the last request but my hope was that the setExpirationSeconds would be refreshed each time the user has a request come through this preDispatch method.

                也許需要使用 cookie?我不需要實際啟動注銷操作,它可以在用戶下次發出請求時處理,如果他們在過去半小時內沒有做任何事情,會話就會被銷毀并且他們被注銷,這意味著如果我走開 45 分鐘,我的屏幕看起來仍然相同,但是如果我單擊鏈接或嘗試提交我已創建的表單,它會將我發送到/login.稍后我可以擔心某種類型的 JS 倒計時警告.

                Maybe a cookie needs used? I don't need to actually initiate a logout action, it can just be handled the next time the user makes a request, if they've not done anything in the last half hour the session is destroyed and they're logged out, meaning if I walk away for 45 minutes my screen still looks the same but if I click a link or try and submit a form I had up it sends me to /login. I can worry about some type of JS countdown warning later.

                如果有人想看,這是我的引導程序:

                Here's my bootstrap if anyone wants to see it:

                class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
                {
                    /**
                     * Custom routes:
                     * 
                     * /login
                     * /logout
                     */
                    protected function _initRoutes()
                    {
                
                        $router = Zend_Controller_Front::getInstance()->getRouter();
                
                        $loginRoute = new Zend_Controller_Router_Route('login', array('controller' => 'auth', 'action' => 'login'));
                
                        $logoutRoute = new Zend_Controller_Router_Route('logout', array('controller' => 'auth', 'action' => 'logout'));
                
                        $routesArray = array('login' => $loginRoute, 'logout' => $logoutRoute);
                
                        $router->addRoutes($routesArray);
                
                    }
                
                    protected function _initPlugins()
                    {
                
                        $frontController = Zend_Controller_Front::getInstance();
                        $frontController->registerPlugin(new Plugin_SessionTrack());
                
                    }
                }
                

                推薦答案

                當您調用 Zend_Session::setExpirationSeconds(10) 時,會話本身實際上在 10 秒后沒有發生任何事情.

                When you call Zend_Session::setExpirationSeconds(10), nothing is actually happening to the session after 10 seconds time per se.

                這個調用導致 Zend_Session 存儲一個內部值,該值標記該會話命名空間從調用時間開始在 time() + $seconds 到期.每次 Zend_Session 開始時,它都會檢查是否有任何會話數據被標記為過期,如果是,則繼續檢查是否過期時間或跳數已經過去.如果是這種情況,則有問題的會話數據在初始化時未設置,因此您的應用程序無法再訪問.

                This call causes Zend_Session to store an internal value marking that session namespace for expiration at time() + $seconds from the time the call is made. Each time a Zend_Session starts, it checks to see if any session data is marked for expiration, and if so proceeds to check to see if the expiration time or hop count has passed. If that is the case, then the session data in question is unset at initialization, and is therefore no longer accessible by your application.

                如果您在每次請求開始時進行此調用,它應該會在每次加載頁面時繼續將會話的生命周期延長數秒.

                If you make this call at the beginning of every request, it should continue to prolong the life of the session by that many seconds on each page load.

                請記住,如果 php.ini 中的會話設置被設置為在 15 分鐘后過期,將命名空間設置為在 60 分鐘后過期不會覆蓋 PHP 的 15 分鐘會話生存期.您可以在 application.ini 文件中對 PHP 的會話指令進行此類調整.

                Keep in mind that if the session settings in php.ini are set to expire the session after 15 minutes, setting a namespace to expire after 60 minutes will not override PHP's session lifetime of 15 minutes. You can make such adjustments to PHP's session directives in your application.ini file.

                在命名空間上設置過期時間還有一個好處,那就是自動刪除一些會話數據,而不必破壞整個會話.

                Setting an expiration on the namespace also has the advantage of automatically removing some session data without having to destroy the entire session.

                我不知道您的應用程序的具體情況,但您可以使用該插件來檢查它們是否已注銷并將請求轉發到您的登錄頁面.您可以在創建命名空間后檢查有效登錄,但您還需要確保當前請求不是登錄嘗試.或者,您可以推遲檢查插件中的有效登錄信息,然后讓您的 ACL 稍后在控制器級別進行處理.

                I don't know the specifics of your application, but you could use the plugin to check and see if they are logged out and forward the request to your login page. You could check for a valid login after creating the namespace, but you also would want to make sure that the current request wasn't a login attempt. Or you could just defer checking for valid login in the plugin and let your ACL handle that later at the controller level.

                您可能還想查看 Zend_Auth,您可以使用它來持久化會話中的身份.身份可以是任何東西,從指示他們是否已登錄的簡單布爾值到實現 Zend_Acl_Role_Interface 的完整用戶對象.Zend Auth 也很容易擴展,因此您可以通過為每個實例使用不同的命名空間來同時激活多個 Zend_Auth 會話,并且可以讓您的自定義身份驗證類為不同的會話命名空間設置不同的時間限制.

                You may also want to look into Zend_Auth which you can use to persist an identity in the session. The identity can be anything from a simple boolean value indicating if they are logged in, to a full blown user object that implements Zend_Acl_Role_Interface. Zend Auth is also easily extended so you can have multiple Zend_Auth sessions active at the same time by using different namespaces for each instance, and could have your custom auth class set different time limits on different session namespaces.

                我希望這有助于回答您的問題,如果您對我所說的有任何疑問,請隨時發表評論.

                I hope that helps answer your question, feel free to comment if you have questions on what I said.

                我測試了以下代碼,它在設定的時間后成功使我的 Zend_Auth 身份過期.我在 60 秒內對其進行了低測試,在等待 60 秒加載頁面后,我不再擁有身份并被注銷".您可以將此添加到您的會話跟蹤插件中.

                I tested the following code and it successfully expired my Zend_Auth identity after the set time. I tested it low with 60 seconds and after waiting 60 seconds to load the page, I no longer had and identity and was "logged out". You could add this to your session track plugin.

                <?php
                $auth = Zend_Auth::getInstance();
                
                if ($auth->hasIdentity()) { // user is logged in
                    // get an instance of Zend_Session_Namespace used by Zend_Auth
                    $authns = new Zend_Session_Namespace($auth->getStorage()->getNamespace());
                
                    // set an expiration on the Zend_Auth namespace where identity is held
                    $authns->setExpirationSeconds(60 * 30);  // expire auth storage after 30 min
                }
                

                這篇關于Zend Framework 不活動后自動注銷的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                Deadlock exception code for PHP, MySQL PDOException?(PHP、MySQL PDOException 的死鎖異常代碼?)
                PHP PDO MySQL scrollable cursor doesn#39;t work(PHP PDO MySQL 可滾動游標不起作用)
                PHP PDO ODBC connection(PHP PDO ODBC 連接)
                Using PDO::FETCH_CLASS with Magic Methods(使用 PDO::FETCH_CLASS 和魔術方法)
                php pdo get only one value from mysql; value that equals to variable(php pdo 只從 mysql 獲取一個值;等于變量的值)
                MSSQL PDO could not find driver(MSSQL PDO 找不到驅動程序)

                    <bdo id='RGx70'></bdo><ul id='RGx70'></ul>
                    <i id='RGx70'><tr id='RGx70'><dt id='RGx70'><q id='RGx70'><span id='RGx70'><b id='RGx70'><form id='RGx70'><ins id='RGx70'></ins><ul id='RGx70'></ul><sub id='RGx70'></sub></form><legend id='RGx70'></legend><bdo id='RGx70'><pre id='RGx70'><center id='RGx70'></center></pre></bdo></b><th id='RGx70'></th></span></q></dt></tr></i><div class="p1p1bf3" id='RGx70'><tfoot id='RGx70'></tfoot><dl id='RGx70'><fieldset id='RGx70'></fieldset></dl></div>

                        <tbody id='RGx70'></tbody>

                          <tfoot id='RGx70'></tfoot>

                          <small id='RGx70'></small><noframes id='RGx70'>

                          <legend id='RGx70'><style id='RGx70'><dir id='RGx70'><q id='RGx70'></q></dir></style></legend>

                          主站蜘蛛池模板: 讲师宝经纪-专业培训机构师资供应商_培训机构找讲师、培训师、讲师经纪就上讲师宝经纪 | 门禁卡_智能IC卡_滴胶卡制作_硅胶腕带-卡立方rfid定制厂家 | 全自动过滤器_反冲洗过滤器_自清洗过滤器_量子除垢环_量子环除垢_量子除垢 - 安士睿(北京)过滤设备有限公司 | RO反渗透设备_厂家_价格_河南郑州江宇环保科技有限公司 | pbt头梳丝_牙刷丝_尼龙毛刷丝_PP塑料纤维合成毛丝定制厂_广州明旺 | 一氧化氮泄露报警器,二甲苯浓度超标报警器-郑州汇瑞埔电子技术有限公司 | 注浆压力变送器-高温熔体传感器-矿用压力传感器|ZHYQ朝辉 | 冷藏车-东风吸污车-纯电动环卫车-污水净化车-应急特勤保障车-程力专汽厂家-程力专用汽车股份有限公司销售二十一分公司 | 防渗膜厂家|养殖防渗膜|水产养殖防渗膜-泰安佳路通工程材料有限公司 | 数显恒温培养摇床-卧式/台式恒温培养摇床|朗越仪器 | 上海赞永| 氧化锆纤维_1800度高温退火炉_1800度高温烧结炉-南京理工宇龙新材料股份有限公司 | 欧美日韩国产一区二区三区不_久久久久国产精品无码不卡_亚洲欧洲美洲无码精品AV_精品一区美女视频_日韩黄色性爱一级视频_日本五十路人妻斩_国产99视频免费精品是看4_亚洲中文字幕无码一二三四区_国产小萍萍挤奶喷奶水_亚洲另类精品无码在线一区 | 土壤养分检测仪_肥料养分检测仪_土壤水分检测仪-山东莱恩德仪器 大型多片锯,圆木多片锯,方木多片锯,板材多片锯-祥富机械有限公司 | 卓能JOINTLEAN端子连接器厂家-专业提供PCB接线端子|轨道式端子|重载连接器|欧式连接器等电气连接产品和服务 | 卓能JOINTLEAN端子连接器厂家-专业提供PCB接线端子|轨道式端子|重载连接器|欧式连接器等电气连接产品和服务 | 半自动预灌装机,卡式瓶灌装机,注射器灌装机,给药器灌装机,大输液灌装机,西林瓶灌装机-长沙一星制药机械有限公司 | 阜阳成人高考_阜阳成考报名时间_安徽省成人高考网 | 无锡网站建设_企业网站定制-网站制作公司-阿凡达网络 | 防勒索软件_数据防泄密_Trellix(原McAfee)核心代理商_Trellix(原Fireeye)售后-广州文智信息科技有限公司 | 算命免费_生辰八字_免费在线算命 - 卜算子算命网 | 电缆接头_防水接头_电缆防水接头 - 乐清市新豪电气有限公司 | 截齿|煤截齿|采煤机截齿|掘进机截齿|旋挖截齿-山东卓力截齿厂家报价 | 苏州西朗门业-欧盟CE|莱茵UL双认证的快速卷帘门品牌厂家 | 聚氨酯保温钢管_聚氨酯直埋保温管道_聚氨酯发泡保温管厂家-沧州万荣防腐保温管道有限公司 | 杭州顺源过滤机械有限公司官网-压滤机_板框压滤机_厢式隔膜压滤机厂家 | 智慧钢琴-电钢琴-便携钢琴-数码钢琴-深圳市特伦斯乐器有限公司 | 亚克力制品定制,上海嘉定有机玻璃加工制作生产厂家—官网 | 医用空气消毒机-医用管路消毒机-工作服消毒柜-成都三康王 | 气密性检测仪_气密性检测设备_防水测试仪_密封测试仪-岳信仪器 | 东莞市天进机械有限公司-钉箱机-粘箱机-糊箱机-打钉机认准东莞天进机械-厂家直供更放心! | 德国EA可编程直流电源_电子负载,中国台湾固纬直流电源_交流电源-苏州展文电子科技有限公司 | 优秀的临床医学知识库,临床知识库,医疗知识库,满足电子病历四级要求,免费试用 | 质检报告_CE认证_FCC认证_SRRC认证_PSE认证_第三方检测机构-深圳市环测威检测技术有限公司 | 翰墨AI智能写作助手官网_人工智能问答在线AI写作免费一键生成 | 不锈钢水箱生产厂家_消防水箱生产厂家-河南联固供水设备有限公司 | 聚氨酯催化剂K15,延迟催化剂SA-1,叔胺延迟催化剂,DBU,二甲基哌嗪,催化剂TMR-2,-聚氨酯催化剂生产厂家 | 大白菜官网,大白菜winpe,大白菜U盘装系统, u盘启动盘制作工具 | KBX-220倾斜开关|KBW-220P/L跑偏开关|拉绳开关|DHJY-I隔爆打滑开关|溜槽堵塞开关|欠速开关|声光报警器-山东卓信有限公司 | 实体店商新零售|微赢|波后|波后合作|微赢集团 | 无菌检查集菌仪,微生物限度仪器-苏州长留仪器百科|