note
blue_cowdawg
<ul><ul><i>
I want to do My cgi application access only one user at a time.
</i></ul></ul>
<p>
Not sure I understand your rationale. CGI by nature is stateless, meaning in this context that N-number of concurrent connections each capable of logging into your application at the same time. Why you'd want to even try to limit to one user at a time does not make sense to me, but I'll bite.
</p>
<p>
First off you need to find some way of implementing a sense of state in your application, in spite of the fact I just said CGI is stateless by nature. One way of doing that is through the use of session ids and cookies. (I prefer shortbread, but I digress)
</p>
<p>You need to track the session ids somehow and associate those session ids with a userid. Looks like you've attempted to do so given the code you have posted in your original posting.
But there's more to the task, you've only just begun.
</p>
<p>
You may want to use a database for some function of database. I doesn't have to be a relational database such as MySQL, PostgreSQL, Sybase, Oracal, et. al. It can be as uncomplicated as a file in /tmp or /usr/tmp (assuming some form of *nix) where you write the userids and session ids. I'd add one more field to that, last access time/date.
</p>
<p>
The recorded time/date gives you the means of tracking when the user last took a trip through your application. If for each CGI transaction you update that time and date you can also calculate the last time they were seen in the application. If, for instance, they haven't accessed the application in four hours (you can set that threshold lower or higher) you can then automagically log them out and terminate their session. Banks and other financial institutions do that all the time as a security measure.
</p>
<p>
I've given you the theory... I'll let you skull out the code. If you can't get it to work, post what you've tried (a bit more detail than what you've got) and we'll look at it for you.
</p>
<p>
Don't forget to try out some of the wonderful [Tutorials] we have on this website. They may give you more insight into what you are trying to accomplish.
</p>
<div class="pmsig"><div class="pmsig-72516">
<hr>
<font size="-2">
Peter L. Berghold -- Unix Professional<br>
Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg<br>
</font>
</div></div>
924347
924347