469,964 Members | 1,712 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,964 developers. It's quick & easy.

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 1789
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Sameer | last post: by
2 posts views Thread by Nicolas Bottarini | last post: by
6 posts views Thread by Bhavini | last post: by
1 post views Thread by rainxy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.