首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

如何样用cache保存用户登陆后的信息

2012-03-24 
怎么样用cache保存用户登陆后的信息?我以前都是用:Cache[name]海风Cache[username]hhhhhCache

怎么样用cache保存用户登陆后的信息?
我以前都是用:
Cache["name"]="海风";
Cache["username"]="hhhhh";
Cache["email"]="heguochang";

输出时用:
Cache["name"].ToString();
Cache["username"].ToString();
Cache["email"].ToString();

但感觉不好!想问问有什么更好的方法没有?

Cache["user"]=user;
输出时怎么用呀?有什么其它的方法没有?  谢谢!

[解决办法]
要面向对象

建个userinfo实体用来保存用户信息,然后把这个实体保存到cache就好了,读出来的时候再转换成该实体就好了

如:
保存:Cache["user"]=userinfo;
读取:userinfo = (userinfo)Cache["user"];

热点排行