473,625 Members | 2,628 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Stopping multiple logins in ASP.Net

Any thought about how can I stop a user from logging into the application
multiple times. I am using forms authentication.
Nov 18 '05 #1
10 1923
Quite a few methods come to mind. put the userIds in an arraylist and store
that in the application - looping through it and checking for an existing
entry whenever someone logs in. Update your database user table with a
field "isLoggedIn " and set it to true.

The problem with these methods is removing the user when he/she logs
out...it's simply if they explicitely log out, but if they simply close
their browser...you'd need to add a timestamp and clean it up routinely.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Conformix Sales" <sa***@conformi x.com> wrote in message
news:6C******** *********@fe1.c olumbus.rr.com. ..
Any thought about how can I stop a user from logging into the application
multiple times. I am using forms authentication.

Nov 18 '05 #2
If I use a database table with a "isLoggedIn " field and set it to true on
user login, how do I add a timestamp and clean it up routinely?

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Quite a few methods come to mind. put the userIds in an arraylist and
store
that in the application - looping through it and checking for an existing
entry whenever someone logs in. Update your database user table with a
field "isLoggedIn " and set it to true.

The problem with these methods is removing the user when he/she logs
out...it's simply if they explicitely log out, but if they simply close
their browser...you'd need to add a timestamp and clean it up routinely.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Conformix Sales" <sa***@conformi x.com> wrote in message
news:6C******** *********@fe1.c olumbus.rr.com. ..
Any thought about how can I stop a user from logging into the application
multiple times. I am using forms authentication.


Nov 18 '05 #3
Well, what I would do is add a second field "lastLogged In" as a datetime
and set it to getDate() at the same time you set the IsLoggedIn to true.

Before accepting a login from a user, if lastLoggedIn > 30 minutes (for
example), I would set isLoggedIn to false
then I would only accept logins from people who's isLoggedIn is false

You could make it even better and update the lastLoggedIn field for every
page hit...this would let you be far more responsive...yo u could change the
maximum login time to 5-10 minutes...depen ding on what type of application
you have and how often you expect users to hit a new page..

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Leon" <vn*****@msn.co m> wrote in message
news:ut******** ******@TK2MSFTN GP09.phx.gbl...
If I use a database table with a "isLoggedIn " field and set it to true on
user login, how do I add a timestamp and clean it up routinely?

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Quite a few methods come to mind. put the userIds in an arraylist and
store
that in the application - looping through it and checking for an existing entry whenever someone logs in. Update your database user table with a
field "isLoggedIn " and set it to true.

The problem with these methods is removing the user when he/she logs
out...it's simply if they explicitely log out, but if they simply close
their browser...you'd need to add a timestamp and clean it up routinely.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Conformix Sales" <sa***@conformi x.com> wrote in message
news:6C******** *********@fe1.c olumbus.rr.com. ..
Any thought about how can I stop a user from logging into the application multiple times. I am using forms authentication.



Nov 18 '05 #4
But how do you catch if a user simply close
their browser?

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:u%******** ************@TK 2MSFTNGP15.phx. gbl...
Well, what I would do is add a second field "lastLogged In" as a datetime
and set it to getDate() at the same time you set the IsLoggedIn to true.

Before accepting a login from a user, if lastLoggedIn > 30 minutes (for
example), I would set isLoggedIn to false
then I would only accept logins from people who's isLoggedIn is false

You could make it even better and update the lastLoggedIn field for every
page hit...this would let you be far more responsive...yo u could change
the
maximum login time to 5-10 minutes...depen ding on what type of application
you have and how often you expect users to hit a new page..

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Leon" <vn*****@msn.co m> wrote in message
news:ut******** ******@TK2MSFTN GP09.phx.gbl...
If I use a database table with a "isLoggedIn " field and set it to true on
user login, how do I add a timestamp and clean it up routinely?

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
> Quite a few methods come to mind. put the userIds in an arraylist and
> store
> that in the application - looping through it and checking for an existing > entry whenever someone logs in. Update your database user table with a
> field "isLoggedIn " and set it to true.
>
> The problem with these methods is removing the user when he/she logs
> out...it's simply if they explicitely log out, but if they simply close
> their browser...you'd need to add a timestamp and clean it up
> routinely.
>
> Karl
>
> --
> MY ASP.Net tutorials
> http://www.openmymind.net/
>
>
> "Conformix Sales" <sa***@conformi x.com> wrote in message
> news:6C******** *********@fe1.c olumbus.rr.com. ..
>> Any thought about how can I stop a user from logging into the application >> multiple times. I am using forms authentication.
>>
>>
>
>



Nov 18 '05 #5
You'll always have that problem. That's wha tthe lastLoggedIn time is
for.....if they've been idle for 5 minutes, you can reset the account and
assume they simply closed their browser. You can also use javascript events
such as onbeforeunload in IE to work some magic...but I agree it'll always
be a problem...it's your only real solution though...

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Leon" <vn*****@msn.co m> wrote in message
news:Ot******** ******@TK2MSFTN GP15.phx.gbl...
But how do you catch if a user simply close
their browser?

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:u%******** ************@TK 2MSFTNGP15.phx. gbl...
Well, what I would do is add a second field "lastLogged In" as a datetime and set it to getDate() at the same time you set the IsLoggedIn to true.

Before accepting a login from a user, if lastLoggedIn > 30 minutes (for
example), I would set isLoggedIn to false
then I would only accept logins from people who's isLoggedIn is false

You could make it even better and update the lastLoggedIn field for every page hit...this would let you be far more responsive...yo u could change
the
maximum login time to 5-10 minutes...depen ding on what type of application you have and how often you expect users to hit a new page..

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Leon" <vn*****@msn.co m> wrote in message
news:ut******** ******@TK2MSFTN GP09.phx.gbl...
If I use a database table with a "isLoggedIn " field and set it to true on user login, how do I add a timestamp and clean it up routinely?

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
> Quite a few methods come to mind. put the userIds in an arraylist and
> store
> that in the application - looping through it and checking for an

existing
> entry whenever someone logs in. Update your database user table with a > field "isLoggedIn " and set it to true.
>
> The problem with these methods is removing the user when he/she logs
> out...it's simply if they explicitely log out, but if they simply close > their browser...you'd need to add a timestamp and clean it up
> routinely.
>
> Karl
>
> --
> MY ASP.Net tutorials
> http://www.openmymind.net/
>
>
> "Conformix Sales" <sa***@conformi x.com> wrote in message
> news:6C******** *********@fe1.c olumbus.rr.com. ..
>> Any thought about how can I stop a user from logging into the

application
>> multiple times. I am using forms authentication.
>>
>>
>
>



Nov 18 '05 #6
Thanks!

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
You'll always have that problem. That's wha tthe lastLoggedIn time is
for.....if they've been idle for 5 minutes, you can reset the account and
assume they simply closed their browser. You can also use javascript
events
such as onbeforeunload in IE to work some magic...but I agree it'll always
be a problem...it's your only real solution though...

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Leon" <vn*****@msn.co m> wrote in message
news:Ot******** ******@TK2MSFTN GP15.phx.gbl...
But how do you catch if a user simply close
their browser?

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:u%******** ************@TK 2MSFTNGP15.phx. gbl...
> Well, what I would do is add a second field "lastLogged In" as a datetime > and set it to getDate() at the same time you set the IsLoggedIn to
> true.
>
> Before accepting a login from a user, if lastLoggedIn > 30 minutes (for
> example), I would set isLoggedIn to false
> then I would only accept logins from people who's isLoggedIn is false
>
> You could make it even better and update the lastLoggedIn field for every > page hit...this would let you be far more responsive...yo u could change
> the
> maximum login time to 5-10 minutes...depen ding on what type of application > you have and how often you expect users to hit a new page..
>
> Karl
> --
> MY ASP.Net tutorials
> http://www.openmymind.net/
>
>
> "Leon" <vn*****@msn.co m> wrote in message
> news:ut******** ******@TK2MSFTN GP09.phx.gbl...
>> If I use a database table with a "isLoggedIn " field and set it to true on >> user login, how do I add a timestamp and clean it up routinely?
>>
>> "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
>> net>
>> wrote in message news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
>> > Quite a few methods come to mind. put the userIds in an arraylist
>> > and
>> > store
>> > that in the application - looping through it and checking for an
> existing
>> > entry whenever someone logs in. Update your database user table
>> > with a >> > field "isLoggedIn " and set it to true.
>> >
>> > The problem with these methods is removing the user when he/she logs
>> > out...it's simply if they explicitely log out, but if they simply close >> > their browser...you'd need to add a timestamp and clean it up
>> > routinely.
>> >
>> > Karl
>> >
>> > --
>> > MY ASP.Net tutorials
>> > http://www.openmymind.net/
>> >
>> >
>> > "Conformix Sales" <sa***@conformi x.com> wrote in message
>> > news:6C******** *********@fe1.c olumbus.rr.com. ..
>> >> Any thought about how can I stop a user from logging into the
> application
>> >> multiple times. I am using forms authentication.
>> >>
>> >>
>> >
>> >
>>
>>
>
>



Nov 18 '05 #7
May I know why you are not considering Session variables

kumar
-----Original Message-----
But how do you catch if a user simply close
their browser?

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>wrote in message news:u%23S%23%

23***********@T K2MSFTNGP15.phx .gbl...
Well, what I would do is add a second field "lastLogged In" as a datetime and set it to getDate() at the same time you set the IsLoggedIn to true.
Before accepting a login from a user, if lastLoggedIn > 30 minutes (for example), I would set isLoggedIn to false
then I would only accept logins from people who's isLoggedIn is false
You could make it even better and update the lastLoggedIn field for every page hit...this would let you be far more responsive...yo u could change the
maximum login time to 5-10 minutes...depen ding on what type of application you have and how often you expect users to hit a new page..
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Leon" <vn*****@msn.co m> wrote in message
news:ut******** ******@TK2MSFTN GP09.phx.gbl...
If I use a database table with a "isLoggedIn " field and set it to true on user login, how do I add a timestamp and clean it up routinely?
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in message news:% 23************* **@TK2MSFTNGP10 .phx.gbl... > Quite a few methods come to mind. put the userIds in an arraylist and > store
> that in the application - looping through it and checking for an
existing
> entry whenever someone logs in. Update your
database user table with a > field "isLoggedIn " and set it to true.
>
> The problem with these methods is removing the user when he/she logs > out...it's simply if they explicitely log out, but if they simply close > their browser...you'd need to add a timestamp and clean it up > routinely.
>
> Karl
>
> --
> MY ASP.Net tutorials
> http://www.openmymind.net/
>
>
> "Conformix Sales" <sa***@conformi x.com> wrote in message > news:6C******** *********@fe1.c olumbus.rr.com. ..
>> Any thought about how can I stop a user from

logging into the application
>> multiple times. I am using forms authentication.
>>
>>
>
>


.

Nov 18 '05 #8
What do you mean?

"Kumar Reddi" <Ku********@REM OVETHIS.GMAIL.C OM> wrote in message
news:3a******** *************** *****@phx.gbl.. .
May I know why you are not considering Session variables

kumar
-----Original Message-----
But how do you catch if a user simply close
their browser?

"Karl Seguin" <karl REMOVE @ REMOVE openmymind

REMOVEMETOO . ANDME net>
wrote in message news:u%23S%23%

23***********@T K2MSFTNGP15.phx .gbl...
Well, what I would do is add a second field "lastLogged In" as a datetime and set it to getDate() at the same time you set the IsLoggedIn to true.
Before accepting a login from a user, if lastLoggedIn > 30 minutes (for example), I would set isLoggedIn to false
then I would only accept logins from people who's isLoggedIn is false
You could make it even better and update the lastLoggedIn field for every page hit...this would let you be far more responsive...yo u could change the
maximum login time to 5-10 minutes...depen ding on what type of application you have and how often you expect users to hit a new page..
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Leon" <vn*****@msn.co m> wrote in message
news:ut******** ******@TK2MSFTN GP09.phx.gbl...
If I use a database table with a "isLoggedIn " field and set it to true on user login, how do I add a timestamp and clean it up routinely?
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in message news:% 23************* **@TK2MSFTNGP10 .phx.gbl... > Quite a few methods come to mind. put the userIds in an arraylist and > store
> that in the application - looping through it and checking for an existing
> entry whenever someone logs in. Update your database user table with a > field "isLoggedIn " and set it to true.
>
> The problem with these methods is removing the user when he/she logs > out...it's simply if they explicitely log out, but if they simply close > their browser...you'd need to add a timestamp and clean it up > routinely.
>
> Karl
>
> --
> MY ASP.Net tutorials
> http://www.openmymind.net/
>
>
> "Conformix Sales" <sa***@conformi x.com> wrote in message > news:6C******** *********@fe1.c olumbus.rr.com. ..
>> Any thought about how can I stop a user from logging into the application
>> multiple times. I am using forms authentication.
>>
>>
>
>

.

Nov 18 '05 #9
Why dont you add the username to a session variable, like
Session["userName"] = "something" ; Then keep checking the
existence of this session variable. Session has a fixed
timeout period. By default 20 minutes idle time, after
which all the session variables are cleared. So, this
saves you from multiple calls to database. Asp.Net take
care of session clearance, if the user closes the browser.

Kumar
-----Original Message-----
What do you mean?

"Kumar Reddi" <Ku********@REM OVETHIS.GMAIL.C OM> wrote in messagenews:3a******* *************** ******@phx.gbl. ..
May I know why you are not considering Session variables

kumar
-----Original Message-----
But how do you catch if a user simply close
their browser?

"Karl Seguin" <karl REMOVE @ REMOVE openmymind

REMOVEMETOO . ANDME net>
wrote in message news:u%23S%23%

23***********@T K2MSFTNGP15.phx .gbl...
Well, what I would do is add a second

field "lastLogged In" as a datetime
and set it to getDate() at the same time you set the

IsLoggedIn to true.

Before accepting a login from a user, if lastLoggedIn
30 minutes (for
example), I would set isLoggedIn to false
then I would only accept logins from people who's

isLoggedIn is false

You could make it even better and update the

lastLoggedIn field for every
page hit...this would let you be far more

responsive...yo u could change
the
maximum login time to 5-10 minutes...depen ding on what

type of application
you have and how often you expect users to hit a new

page..

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Leon" <vn*****@msn.co m> wrote in message
news:ut******** ******@TK2MSFTN GP09.phx.gbl...
> If I use a database table with a "isLoggedIn " field

and set it to true on
> user login, how do I add a timestamp and clean it up

routinely?
>
> "Karl Seguin" <karl REMOVE @ REMOVE openmymind

REMOVEMETOO . ANDME net>
> wrote in message news:%

23************* **@TK2MSFTNGP10 .phx.gbl...
> > Quite a few methods come to mind. put the userIds

in an arraylist and
> > store
> > that in the application - looping through it and

checking for an
existing
> > entry whenever someone logs in. Update your

database user table with a
> > field "isLoggedIn " and set it to true.
> >
> > The problem with these methods is removing the user

when he/she logs
> > out...it's simply if they explicitely log out, but

if they simply close
> > their browser...you'd need to add a timestamp and

clean it up
> > routinely.
> >
> > Karl
> >
> > --
> > MY ASP.Net tutorials
> > http://www.openmymind.net/
> >
> >
> > "Conformix Sales" <sa***@conformi x.com> wrote in

message
> > news:6C******** *********@fe1.c olumbus.rr.com. ..
> >> Any thought about how can I stop a user from

logging into the
application
> >> multiple times. I am using forms authentication.
> >>
> >>
> >
> >
>
>


.

.

Nov 18 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
5998
by: Steve Meier | last post by:
Environment: SQLServer Developer Edition on Machine A Enterprise Manager running on remote machine B Both machines are in the same subnet I open Enterprise Mgr on Machine A, right click on the Stored Proc, enter the parameters and the debugger stops on the first line and I can single
4
417
by: William Logan | last post by:
Hello all DBAs what is the best methodolgy to replace a server with a new server in a multiple sql server environment.. Is is using back up/restore to another/bridge type server then rename servers or is it to bring in new server then tranfer the datafiles. Does tranfering the data files include logins and jobs ?? Or is ther a better way that I have not realised? Bill
1
2508
by: Sameer | last post by:
one important problem i am facing is that my web solution (asp.net) will be deployed on a webfarm. I am using sql server session management on clustered sqlservers. but as i need to prevent multiple logins through a username/password (same credentials at a time) on the website. also session_end() event does not fire in sql server mode. one solution is sychronized cache of webservers. and
2
2118
by: Shashi | last post by:
My development environment is ASP.Net 1.1. When the user does multiple logins to the system and navigates to different screens and clicks back button sometimes it reading the session variables values are mixing each other. How to avoid this kind of situation? Basically I am looking for the steps to be taken when we develop web based application using ASP.Net (.Net framework 1.1) for multiple logins.
6
4372
by: anoj | last post by:
Hi All i need to prevent multiple logins from the same user at the same time. what is the best way to do this . How can i detect if a user closes the browser window without logging out so tht his/her id can be removed from the global list maintained for the looged in users
2
2884
by: Nicolas Bottarini | last post by:
Hi!! I have a site with a backend subdirectory with the backend of the site. I need that the site to have one login and the backend directory another one. Is this possible with Forms Authentication?? What can i do?? Thanks Nicolas
18
3384
by: Gleep | last post by:
I've searched google intensely on this topic and it seems noone really knows how to approch this. The goal I don't want clients to give out their usernames and passwords to friends, since the site relies on subscrption fees. Sessions ID's are matched between the browser and the server. So a users can login with same username and password and those sessions are tracked individually. Some suggest create table fields with the session ID...
1
955
by: Paul | last post by:
Hi, The problem.... We have 2 webservers, behind a Load Balancer. We have set the website on both boxes to store sessions in SQLServer. To prevent people sharing the logins, we have utilised the following article http://www.eggheadcafe.com/articles/20030418.asp (Which stores
6
6197
by: Bhavini | last post by:
Hi All, I have to prevent multiple logins for the same user accessing at same time. i.e. if xyz user is active, no other login should be allowed for the same user ID. I thought of saving active falg in databse. but when user closes browser or anyhow regular logoff procedure is not called then that user will always be in active state. So next time he will not be allowed to login.
0
8251
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
8182
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
8688
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
8635
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
8352
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,...
1
6115
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
4188
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2614
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1496
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.