Hi,
I have been working on an application which involves login control.
I am using session variable for maintaining session.
i want one variable(string array) just to keep track of users logging in so that they can't login again.
I tried creating in Gloabl.asax file but its not getting shown in class file.
Any solutions?
Loading
Jaish MathewsPosted Jan 9, 2011, 2:22 AM
You can do it using global.asax and static variable. Below code sees working for me.
Write the code in session start event.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using System.Collections.Specialized;
namespace WebApplication1
{
public class Global : System.Web.HttpApplication
{
public static StringCollection users = new StringCollection();
void Session_Start(object sender, EventArgs e)
{
// Code that runs when a new session is started
string windowsUser = Environment.UserName;
if (!users.Contains(windowsUser))
{
users.Add(windowsUser);
}
else
{
Response.Redirect("error.html");
}
}
void Session_End(object sender, EventArgs e)
{
}
}