question - how to limit 1 access at a time

Discussion to talk about software related topics only.
Post Reply
cnth98
Posts: 14
Joined: Wed Dec 01, 2010 8:15 am

question - how to limit 1 access at a time

Post by cnth98 »

My program has control page and setup web pages. How can I limit to one person at a time to access the setup page?

How do I find out the request for the setup page is from what ip address?
greengene
Posts: 164
Joined: Wed May 14, 2008 11:20 am
Location: Lakeside, CA

Re: question - how to limit 1 access at a time

Post by greengene »

you can use SetNewGetHandler() to setup up your own get handler.
then in your Get function, you can use GetSocketRemoteAddr(sock) to
get the IP for the current request.

if you do that, you can know at least who was the last IP to request
your page. to find out if they still have it open can be problematic. some
basic html/javascript can be used if the page is closed nicely, but to
capture the other cases, you have to be a bit more creative.

but given that you know that it is already in use, you can RedirectResponse()
to some other page to tell them it is already in use, or build/send your own
HTTP403 error.
rnixon
Posts: 833
Joined: Thu Apr 24, 2008 3:59 pm

Re: question - how to limit 1 access at a time

Post by rnixon »

Not sure what the best solution is, but one way would be to create a login scheme with a timeout for inactivity. HTTP is connectionless, so you either need to get fancy with the scripts as in the previous post, or do something like this. The login will also be a LOT of work, maintaining users, passwords, a database, etc. I would try to see if there was some way to configure my app so that this was not necessary. For example, what is the difference if someone can just change the configuration a few minutes later?
galto
Posts: 3
Joined: Sat Dec 11, 2010 4:28 pm

Re: question - how to limit 1 access at a time

Post by galto »

I might not fully understand you application, but I would use cookies as keep updating the stream of POST or cookie data as you move along (how some SOHO routers used to work)
User accesses main screen (login or just click next) and is provided a new cookie if no other cookies exist that has been recently accessed by another user.
If a cookie does exist, but has "expired" for what ever reason, the cookie the net burner knows about gets replaced.
Continued access to subsequent pages requires the user provide the one and only cookie you keep state space of.
3 issues off I can think of:
1.) Need to have an "auto-refresh" or otherwise reset the cookie (new http request fairly frequently via AJAX?) to prevent failed/crashed client from eating up time they can't be using (fast timeout)
2.) Need to have a inactivity timer to prevent one user from eating up the resource when they leave the browser untended for a long time.
3.) Incomplete configurations, depending on the length of the config data, it could take some time for a user to never complete the configuration process. How bad is it for your end application to be in some half-complete configuration? (why I suggesed post/form data or local data associated with the cookie)
cnth98
Posts: 14
Joined: Wed Dec 01, 2010 8:15 am

Re: question - how to limit 1 access at a time

Post by cnth98 »

Thanks everyone for the help and tips, really appreciated.
Post Reply