首页 > 代码库 > session相关----高手请跳过!

session相关----高手请跳过!

session[“username”]=null;//Session.Remove(“username”);的结果是session[“username”]=null了

session[“username”]=””;

session.clear();//表示将会话中所有的session的键值都清空,但是session还是依然存在,同等于Session.RemoveAll()

session.abandon();

//---------------------------------自己写的小栗子----------------------------------------------------------------------------------

Session["username"] = "xxj";
            Response.Write("username:"+Session["username"]);
            //Session.Remove("username");//值为NULL
            //Session.Abandon();//值不为NULL,为xxj
            Session.Clear();//Session.Clear只是清除Session中的所有数据并不会中止该Session,值为NULL

           
            //Response.Write("移除后的username:" + Session["username"]);
            if (Session["username"] == null)
            {
                Response.Write("session[\"username\"]真的为NULL了");
            }
           
            else
            {
                Response.Write("session[\"username\"]不为NULL,session[\"username\"]的值为" + Session["username"]);
            }

参考:http://www.cnblogs.com/shuang121/archive/2011/03/02/1968768.html

session相关----高手请跳过!