using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
namespace OnlineUser
{
public class Global : System.Web.HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
#region OnlineUsers
try
{
DataTable userTable = new DataTable();
userTable.Columns.Add("SessionID");
userTable.Columns.Add("UserIP");
userTable.Columns.Add("Browser");
userTable.Columns.Add("OSName");
userTable.AcceptChanges();
Application.Lock();
Application["OnlineUsers"] = userTable;
Application.UnLock();
}
catch
{ }
#endregion
}
protected void Session_Start(object sender, EventArgs e)
{
//用Cookie是为了防止同一个用户重复计数
HttpCookie cookie = Request.Cookies["user"];
if (null == cookie)//确定是否存在用户输入的cookie
{
cookie = new HttpCookie("user");//创建一个名称是user的cookie对象
cookie.Value = "used";//为该cookie赋值,只能是字符串,非字符串需转换
cookie.Expires = DateTime.Now.AddHou