Verifying the user is connected

R

Robert Scheer

Hi.

My site needs to know if the user is connected before executing some
queries on my database. Actually, I have a page loaded by an Iframe
that runs every 30 seconds and updates a field on my database to tells
me the user is connected. If this field is not updated for more than
one minute I consider the user disconnected.

The problem is, if that page does not load for any anormal reason (an
IIS error like Page Could not be Loaded, for example), my database
won't be updated, but the user is connected!

What is the best way to detect a user is connected on your site? I read
about an element on the Machine.config file called
clientConnectedCheck. Can it be used for that kind of verification?

Thanks,
Robert Scheer
 
S

S. Justin Gengo

Robert,

Technically, after each page is delivered to the client the user is no
longer connected to your website.

That is why session state was invented. Session state is simply a timer that
gets reset every time a user connects to the server. How does the server
know which user is currently connecting? The first time a "new" user
connects to the server and begins a new session a cookie is stored on the
server.

I would suggest that you use the user session to check if a user is still
connected and set it for longer than a single connection to your iFrame
refresh. So if your iFrame refreshes once a minute and you want to give a
user up to three tries to connect set your session timeout to three minutes
and twenty seconds or something similar to that logic.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top