Extjs 4会话管理 [英] Extjs 4 Session Management

查看:162
本文介绍了Extjs 4会话管理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用基于Web的应用程序,其中用户会话必须进行管理管理。



在app.js中,我使用了启动配置:

 启动:function(){
Ext.create('myproject.view.LoginForm')
}

LoginForm:将显示登录对话框,并调用登录控制器与服务器进行通信,以验证用户提供的凭据。



所以当用户刷新页面Extjs要求登录是因为我没有在这里检查会话,应该如何存储在Extjs中的会话详细信息客户端并检查以避免提示登录,除非用户有注销?如何管理用户会话?

解决方案

会话管理可以使用



内部登录控制器

  //将用户详细信息存储在会话/ Cookie 
Ext.util.Cookies.set(key,value);

退出按钮

  //从Cookie中删除用户详细信息
Ext.util.Cookies.set(key,value);

在App.js

  autoCreateViewport:false,

启动:function(){

var key = Ext.util.Cookies.get (键);

if(key === undefined || key =='null'|| key == null || key.length< = 0){
//加载登录界面为用户没有登录
Ext.create('app.view.LoginForm');
}
else {
//加载主UI,因为用户已经登录
Ext.create(app.view.Viewport);
}
}


I am having web based application in which user session has to be managed management.

In app.js I have used launch config as :

launch: function(){
    Ext.create('myproject.view.LoginForm')
}

LoginForm : will show log in dialog and invoke login controller for communicating with server for authenticating the credentials provided by the user.

So when ever user refreshes the page Extjs is asking for log in that is because of I am not checking the session in here, How should be the session details stored in Extjs client and check to avoid prompting the log in unless user has log-out ? and How to manage user session ?

解决方案

Session Management can be done using

Inside login controller

// Storing user details in session / cookies 
Ext.util.Cookies.set("key", value); 

On logout button

// remove user details from cookies
Ext.util.Cookies.set("key", value); 

In App.js

autoCreateViewport: false,

launch: function(){

    var key= Ext.util.Cookies.get("key");

    if (key=== undefined || key== 'null' || key== null || key.length <= 0){
        // load login UI as user is not logged in
        Ext.create('app.view.LoginForm');
    }
    else {
        // load main UI as user is already logged in
        Ext.create("app.view.Viewport");
    }
}

这篇关于Extjs 4会话管理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆