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>

                          主站蜘蛛池模板: 深圳希玛林顺潮眼科医院(官网)│深圳眼科医院│医保定点│香港希玛林顺潮眼科中心连锁品牌 | 水平垂直燃烧试验仪-灼热丝试验仪-漏电起痕试验仪-针焰试验仪-塑料材料燃烧检测设备-IP防水试验机 | 湿地保护| PCB设计,PCB抄板,电路板打样,PCBA加工-深圳市宏力捷电子有限公司 | 武汉印刷厂-不干胶标签印刷厂-武汉不干胶印刷-武汉标签印刷厂-武汉标签制作 - 善进特种标签印刷厂 | 汽车整车综合环境舱_军标砂尘_盐雾试验室试验箱-无锡苏南试验设备有限公司 | 温州食堂承包 - 温州市尚膳餐饮管理有限公司 | 上海道勤塑化有限公司| 无轨电动平车_轨道平车_蓄电池电动平车★尽在新乡百特智能转运设备有限公司 | 双齿辊破碎机-大型狼牙破碎机视频-对辊破碎机价格/型号图片-金联机械设备生产厂家 | 泰来华顿液氮罐,美国MVE液氮罐,自增压液氮罐,定制液氮生物容器,进口杜瓦瓶-上海京灿精密机械有限公司 | 中空玻璃生产线,玻璃加工设备,全自动封胶线,铝条折弯机,双组份打胶机,丁基胶/卧式/立式全自动涂布机,玻璃设备-山东昌盛数控设备有限公司 | 空调风机,低噪声离心式通风机,不锈钢防爆风机,前倾皮带传动风机,后倾空调风机-山东捷风风机有限公司 | 全自动不干胶贴标机_套标机-上海今昂贴标机生产厂家 | 卡诺亚轻高定官网_卧室系统_整家定制_定制家居_高端定制_全屋定制加盟_定制家具加盟_定制衣柜加盟 | 螺杆式冷水机-低温冷水机厂家-冷冻机-风冷式-水冷式冷水机-上海祝松机械有限公司 | 影像测量仪_三坐标测量机_一键式二次元_全自动影像测量仪-广东妙机精密科技股份有限公司 | 精密交叉滚子轴承厂家,转盘轴承,YRT转台轴承-洛阳千协轴承 | 电脑知识|软件|系统|数据库|服务器|编程开发|网络运营|知识问答|技术教程文章 - 好吧啦网 | 金环宇|金环宇电线|金环宇电缆|金环宇电线电缆|深圳市金环宇电线电缆有限公司|金环宇电缆集团 | 考试试题_试卷及答案_诗词单词成语 - 优易学 | 雾度仪_雾度计_透光率雾度仪价格-三恩时(3nh)光电雾度仪厂家 | 电液推杆生产厂家|电动推杆|液压推杆-扬州唯升机械有限公司 | 地磅-地秤-江阴/无锡地磅-江阴天亿计量设备有限公司_ | 高精度电阻回路测试仪-回路直流电阻测试仪-武汉特高压电力科技有限公司 | OLChemim试剂-ABsciex耗材-广州市自力色谱科仪有限公司 | Duoguan 夺冠集团| 北京租车牌|京牌指标租赁|小客车指标出租 | 扬子叉车厂家_升降平台_电动搬运车|堆高车-扬子仓储叉车官网 | 郑州爱婴幼师学校_专业幼师培训_托育师培训_幼儿教育培训学校 | 可程式恒温恒湿试验箱|恒温恒湿箱|恒温恒湿试验箱|恒温恒湿老化试验箱|高低温试验箱价格报价-广东德瑞检测设备有限公司 | 英国雷迪地下管线探测仪-雷迪RD8100管线仪-多功能数字听漏仪-北京迪瑞进创科技有限公司 | 武汉EPS线条_EPS装饰线条_EPS构件_湖北博欧EPS线条厂家 | 小程序开发公司-小程序制作-微信小程序开发-小程序定制-咏熠软件 | 钢格栅板_钢格板网_格栅板-做专业的热镀锌钢格栅板厂家-安平县迎瑞丝网制造有限公司 | 家德利门业,家居安全门,别墅大门 - 安徽家德利门业有限公司 | 断桥铝破碎机_铝合金破碎机_废铁金属破碎机-河南鑫世昌机械制造有限公司 | 高效节能电机_伺服主轴电机_铜转子电机_交流感应伺服电机_图片_型号_江苏智马科技有限公司 | 青岛美佳乐清洁工程有限公司|青岛油烟管道清洗|酒店|企事业单位|学校工厂厨房|青岛油烟管道清洗 插针变压器-家用电器变压器-工业空调变压器-CD型电抗器-余姚市中驰电器有限公司 | 滚筒烘干机_转筒烘干机_滚筒干燥机_转筒干燥机_回转烘干机_回转干燥机-设备生产厂家 | 长沙网站建设制作「网站优化推广」-网页设计公司-速马科技官网 |