flex 登录时记住用户名和密码功能实现

此方法记住用户名和密码是跨浏览器的,因为保存用户名和密码的的文件保存在本地flash文件中
第一步,存放用户名和密码在flash本地文件中
var userInfoCookie:SharedObject = SharedObject.getLocal("userInfoCookie");
if(rememberUsernameAndPassword.selected) {
userInfoCookie.data.userName = login.username.text;
userInfoCookie.data.password = login.password.text;
userInfoCookie.data.isRememberUsernameAndPassword = true;
} else {
userInfoCookie.data.userName = "";
userInfoCookie.data.password = "";
userInfoCookie.data.isRememberUsernameAndPassword = false;
}
userInfoCookie.flush();
第二步
var userInfoCookie:SharedObject = SharedObject.getLocal("userInfoCookie");
if(userInfoCookie.data.hasOwnProperty("userName") && userInfoCookie.data.isRememberUsernameAndPassword
&& userInfoCookie.data.userName != "") {
this.username.text = userInfoCookie.data.userName;
this.password.text = userInfoCookie.data.password;
this.rememberUsernameAndPassword.selected = true;
}

你可能感兴趣的:(Flash,sharedobject,userinfocookie,记住用户名和密码)