473,503 Members | 1,834 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 1911
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***@conformix.com> wrote in message
news:6C*****************@fe1.columbus.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****************@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***@conformix.com> wrote in message
news:6C*****************@fe1.columbus.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 "lastLoggedIn" 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...you could change the
maximum login time to 5-10 minutes...depending 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.com> wrote in message
news:ut**************@TK2MSFTNGP09.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****************@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***@conformix.com> wrote in message
news:6C*****************@fe1.columbus.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%********************@TK2MSFTNGP15.phx.gbl.. .
Well, what I would do is add a second field "lastLoggedIn" 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...you could change
the
maximum login time to 5-10 minutes...depending 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.com> wrote in message
news:ut**************@TK2MSFTNGP09.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****************@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***@conformix.com> wrote in message
> news:6C*****************@fe1.columbus.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.com> wrote in message
news:Ot**************@TK2MSFTNGP15.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%********************@TK2MSFTNGP15.phx.gbl.. .
Well, what I would do is add a second field "lastLoggedIn" 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...you could change
the
maximum login time to 5-10 minutes...depending 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.com> wrote in message
news:ut**************@TK2MSFTNGP09.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****************@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***@conformix.com> wrote in message
> news:6C*****************@fe1.columbus.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****************@TK2MSFTNGP10.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.com> wrote in message
news:Ot**************@TK2MSFTNGP15.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%********************@TK2MSFTNGP15.phx.gbl.. .
> Well, what I would do is add a second field "lastLoggedIn" 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...you could change
> the
> maximum login time to 5-10 minutes...depending 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.com> wrote in message
> news:ut**************@TK2MSFTNGP09.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****************@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***@conformix.com> wrote in message
>> > news:6C*****************@fe1.columbus.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***********@TK2MSFTNGP15.phx.gbl...
Well, what I would do is add a second field "lastLoggedIn" 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...you could change the
maximum login time to 5-10 minutes...depending 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.com> wrote in message
news:ut**************@TK2MSFTNGP09.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***@conformix.com> wrote in message > news:6C*****************@fe1.columbus.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********@REMOVETHIS.GMAIL.COM> 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***********@TK2MSFTNGP15.phx.gbl...
Well, what I would do is add a second field "lastLoggedIn" 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...you could change the
maximum login time to 5-10 minutes...depending 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.com> wrote in message
news:ut**************@TK2MSFTNGP09.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***@conformix.com> wrote in message > news:6C*****************@fe1.columbus.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********@REMOVETHIS.GMAIL.COM> 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***********@TK2MSFTNGP15.phx.gbl...
Well, what I would do is add a second

field "lastLoggedIn" 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...you could change
the
maximum login time to 5-10 minutes...depending 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.com> wrote in message
news:ut**************@TK2MSFTNGP09.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***@conformix.com> wrote in

message
> > news:6C*****************@fe1.columbus.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
how do I keep checking the existence of this session variable even if the
user closes the browser?

"Kumar Reddi" <Ku********@REMOVETHIS.GMAIL.COM> wrote in message
news:43****************************@phx.gbl...
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********@REMOVETHIS.GMAIL.COM> 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***********@TK2MSFTNGP15.phx.gbl...
> Well, what I would do is add a second
field "lastLoggedIn" 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...you could change
> the
> maximum login time to 5-10 minutes...depending 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.com> wrote in message
> news:ut**************@TK2MSFTNGP09.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***@conformix.com> wrote in
message
>> > news:6C*****************@fe1.columbus.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 #11

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

Similar topics

4
5993
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...
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...
1
2495
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...
2
2112
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...
6
4365
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...
2
2867
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...
18
3363
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...
1
949
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...
6
6193
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...
0
7076
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...
0
7274
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,...
1
6984
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...
0
5576
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4670
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3151
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1507
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 ...
1
732
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
377
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...

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.