Session是什么呢?简单来说就是服务器给客户端的一个编号。当一台WWW服务器运行时,可能有若干个用户浏览正在运正在这台服务器上的网站。当每个用户首次与这台WWW服务器建立连接时,他就与这个服务器建立了一个Session,同时服务器会自动为其分配一个SessionID,用以标识这个用户的唯一身份。这个SessionID是由WWW服务器随机产生的一个由24个字符组成的字符串,我们会在下面的实验中见到它的实际样子。
这个唯一的SessionID是有很大的实际意义的。当一个用户提交了表单时,浏览器会将用户的SessionID自动附加在HTTP头信息中,(这是浏览器的自动功能,用户不会察觉到),当服务器处理完这个表单后,将结果返回给SessionID所对应的用户
如果一个会话结束
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.asp教程x.cs" Inherits="UsingSessionEnd" EnableSessionState="ReadOnly" %>
Using Session State - End
File: Default.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;public partial class UsingSessionEnd : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Session["Name"] == null)
labSession.Text = "Session has timed out or not been initialized";
else
{
string name = (string)Session["Name"];
labSession.Text = name;
}
}
}
使用Cookieless会话状态
The web configuration file enables cookieless sessions by assigning the value AutoDetect to the cookieless attribute.
File: Web.Config
cookieless="AutoDetect"
regenerateExpiredSessionId="true" />
session超时时间
File: Web.Config
You can modify the Session timeout value programmatically with the Timeout property of the Session object.
Session.Timeout = 60;
茶杯头甜蜜终章dlc 官方手机版v1.0.0.3
下载火柴人传说暗影格斗内置菜单 最新版v3.0.1
下载荒野乱斗测试服 安卓版v61.10.3
下载荒野乱斗彩虹服 安卓版v61.10.3
下载寒霜启示录 安卓版v1.25.10
寒霜启示录是一款生存模拟游戏,不少玩家可能对于末日都有着自己
末日城堡免广告版 安卓最新版v0.7.1
末日城堡免广告版是一款非常好玩的模拟经营类游戏,内部可以不看
甜蜜人生模拟器 最新版v1.4.5
甜蜜人生模拟器是一款非常好玩的模拟恋爱手游,玩家在这里能够对
武器锻造师内置功能菜单 v10.4
武器锻造师内置菜单版是游戏的破解版本,在该版本中为玩家提供了
开放空间overfield 安卓版v1.0.5
开放空间Overfield是一款箱庭养成经营手游,让你在广阔