Allowing one user at a time to access a particular PHP Page
Dear Forum,
Thanks for taking time reading this post.
I checked out on sessions and cookies but I guess they are more towards the client side? :S
Is there a way to achieve this: :?:
The PHP program I am doing is to reverse Telnet (Terminal Server and it accessing through CONSOLE port) into a router from a selection of a dropdown list box. Once this user had successfully logged into the router, other users(different computer) will NOT be able to even see this same logged on router as a selection to log in again.
I hope you can understand my question.
Thanks alot people! :*
LiBOC
Junior Poster in Training
73 posts since Jul 2005
Reputation Points: 10
Solved Threads: 1
Well, if you put your routers into a mysql table, then once selected you could flag a column (as being in use).
pritaeas
Posting Expert
5,480 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
One solution could be:
create a temp file called lock.txt.
The file will be created only after a successful login. The file will be deleted after logout.
Before login you check if the file exists and if it does the script stops.
Note:
if for some reason the temp file cannot be deleted. It is a good idea before login to check for last modification time if it is more than 24hours delete the file.
lordspace
Junior Poster in Training
90 posts since May 2006
Reputation Points: 18
Solved Threads: 6
I will try that... thanks so much, even for replying!
LiBOC
Junior Poster in Training
73 posts since Jul 2005
Reputation Points: 10
Solved Threads: 1
Hi,
I tried with the lock.txt. It worked pretty well.
But do you know the coding to check if a file exist or not? I am very new to PHP. Thanks!
Dav
One solution could be:
create a temp file called lock.txt.
The file will be created only after a successful login. The file will be deleted after logout.
Before login you check if the file exists and if it does the script stops.
Note:
if for some reason the temp file cannot be deleted. It is a good idea before login to check for last modification time if it is more than 24hours delete the file.
LiBOC
Junior Poster in Training
73 posts since Jul 2005
Reputation Points: 10
Solved Threads: 1
Oh Hi,
Sorry. I done that detection of existing file already. Thanks,
One solution could be:
create a temp file called lock.txt.
The file will be created only after a successful login. The file will be deleted after logout.
Before login you check if the file exists and if it does the script stops.
Note:
if for some reason the temp file cannot be deleted. It is a good idea before login to check for last modification time if it is more than 24hours delete the file.
LiBOC
Junior Poster in Training
73 posts since Jul 2005
Reputation Points: 10
Solved Threads: 1
Hey hi!
Thanks for replying. Do you know how to pop u an alert window message in PHP?
Thanks,
Dav
use file_exists function
$filename = '/path/to/foo.txt';
if (file_exists($filename)) {
echo "The file $filename exists";
} else {
echo "The file $filename does not exist";
}
LiBOC
Junior Poster in Training
73 posts since Jul 2005
Reputation Points: 10
Solved Threads: 1