473,666 Members | 2,058 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Avoid Concurrent Login in ASP.NET

4 New Member
Hi,

I have a critical problem regarding, avoiding the user to login to wibsite using the same credentials at the same time.The concept is once the user is logged in to application the that user credentials should be locked, i.e. no others should be able to login with that credentials....

What I have tried is with the following code
In web.Config I added following code:
<sessionState
mode="StateServ er"
stateConnection String="tcpip=1 27.0.0.1:42424"
sqlConnectionSt ring="data source=127.0.0. 1;user id=sa;password= letmein"
cookieless="fal se"
timeout="1"
/>

In Global.asax.cs:
protected void Application_Pre RequestHandlerE xecute(Object sender, EventArgs e)
{
// Let's write a message to show this got fired---
Response.Write( "SessionID: " +Session.Sessio nID.ToString() + "User key: " +(string)Sessio n["user"]);
if(Session["user"]!=null) // e.g. this is after an initial logon
{
string sKey=(string)Se ssion["user"];
// Accessing the Cache Item extends the Sliding Expiration automatically
string sUser=(string) HttpContext.Cur rent.Cache[sKey];
}
}

In your Login Page "Login" button handler:
private void Button1_Click(o bject sender, System.EventArg s e)
{
//validate your user here (Forms Auth or Database, for example)
// this could be a new "illegal" logon, so we need to check
// if these credentials are already in the Cache
string sKey=TextBox1.T ext+TextBox2.Te xt;
string sUser=Convert.T oString(Cache[sKey]);
if (sUser==null || sUser==String.E mpty){
// No Cache item, so sesion is either expired or user is new sign-on
// Set the cache item and Session hit-test for this user---
TimeSpan SessTimeOut=new TimeSpan(0,0,Ht tpContext.Curre nt.Session.Time out,0,0);
HttpContext.Cur rent.Cache.Inse rt(sKey,sKey,nu ll,DateTime.Max Value,SessTimeO ut,
System.Web.Cach ing.CacheItemPr iority.NotRemov able,null);
Session["user"]=TextBox1.Text+ TextBox2.Text;
// Let them in - redirect to main page, etc.
Label1.Text="<M arquee><h1>Welc ome!</h1></marquee>";

}
else
{
// cache item exists, so too bad...
Label1.Text="<M arquee><h1><fon t color=red>ILLEG AL LOGIN ATTEMPT!!!</font></h1></marquee>";
return;
}

}


Even though the problem is If the user closes the browser window with Alt+F4 or X button or File----> Close then the user will be kept logged.


Kindly suggest appropriate solution for this problem

Thanks and Regards,
CBK Prasad
Apr 28 '07 #1
0 3236

Sign in to post your reply or Sign up for a free account.

Similar topics

2
4778
by: BenM | last post by:
Description: I would like to prevent a user from logging in with their user/password combination on a different computer or even a different browser window, if they are already logged in. I have a login page, from which I use a DB check to verify user/password info. Also, I have a bit loggedIN field in the DB, which I use to see if they are currently logged in; if so, I prevent them from logging in a second time. Problem: Unless they...
5
3125
by: Veeresh | last post by:
I have written an ASP.Net application and has question regarding page navigation. Aftyer logging in to the web site by clicking on the back button user can go back to the login ASPX page. How to avoid this in ASP.Net ? Thanks Veer
2
2422
by: Calvin KD | last post by:
Hi everyone, Can someone suggest a way of monitoring the number of logins for each user in a particular session to make sure that a particular user cannot log in twice in the same session? I have thought of using Application-level counter or even store the counter in the database but it will not work (100% of the time that is) when the user's session timed out, or user clicking the IE back button or even close down the browser completely....
13
3823
by: Hope Paka | last post by:
I am storing user login information (not password) in the session. I also use, cookieless session. I realized that, if someone copy-pastes the URL after he/she logged in to the system to another person, the other person's browser opens as if the sender logged in. 1) Person A Logins to the system. (login information is stored in SQL Session state) 2) Person A copy-paster the url and sends it to person B (format of the url is...
0
913
by: kmercer46 | last post by:
i create crystal reports thru System DSN of Sql Server in vb.net. when i run these reports on the server where sql server installed these works fine but when ever i run these reports on any client computer its popup the Login Window. how can i avoid this login window. second thing if i give password in poped up login window its give me error like "crystal report viewer connection failed" how to resolve this. If anyone can help me i am ...
2
11174
by: runner7 | last post by:
Can anyone tell me if there is a way in PHP to determine when a session times out on the server or how many concurrent sessions there are in your application?
2
19314
by: mktselvan | last post by:
Hi, Existing running oracle application 11i (11.5.8) Database version is 8.1.7.4 There is any command / way to know the number of concurrent users for this application. select SESSIONS_MAX, SESSIONS_WARNING,
0
1391
by: contactme | last post by:
Hi, Is it possible to open concurrent connections using Net::IMAP::Simple library ? My IMAP server allows 4 connections per ip, so I am having following problems while using Net::IMAP::Simple and Net::IMAP::Simple::SSL libraries: 1) The method new returns a valid connection even on 5th try, though the login fails as it looks like IMAP->login somehow knows that 5th object is not valid..Is it possible ? 2) Somtime, the script fails at the...
0
13327
amitpatel66
by: amitpatel66 | last post by:
There is always a requirement that in Oracle Applications, the Concurrent Program need to be execute programatically based on certain conditions/validations: Concurrent programs can be executed programatically either from UNIX or Oracle PLSQL. In this Section, I will be explaining about calling a Concurrent program from UNIX using the CONCSUB Command. Pre-requisite: 1. Concurrent Program should be registered in oracle Applications...
0
8444
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8356
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8869
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8781
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8551
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8639
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6198
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4368
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.