如何存session,取session

存session:

Session["codes"] =要存的session字段

用哈希函数存多个:

System.Collections.Hashtable hs = new System.Collections.Hashtable();
hs.Add("code", codes); //存验证码
hs.Add("codetime",DateTime.Now.AddMinutes(15)); //验证码有效期15分钟

 

取session:

Session["codes"]   //直接这样就好啦

用哈希函数取:

System.Collections.Hashtable ht = new System.Collections.Hashtable();
ht = Session["codes"] as System.Collections.Hashtable;

posted @ 2016-06-27 10:53  小鹿的无名书  阅读(495)  评论(0编辑  收藏  举报