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! :*

Well, if you put your routers into a mysql table, then once selected you could flag a column (as being in use).

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.

Comments
Smart Answer...

I will try that... thanks so much, even for replying!

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.

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";
}

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.

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";
}

something like:

echo '<script type="text/javascript">
            alert("hello");
         </script>';

but this is not recommended..

I WANT THAT IF A USER LOGIN BY USING ONE USER ID AND PASSWORD. That same should't be used for login from another machine. To prevent this i make a table in database which gets updated as soon as user gets login and at logout that table deletes user login information. but facing issue when user dont press logout button and turns of browser directly or system gets off suddenely due to power supply then how to prevent this..

This article has been dead for over six months. Start a new discussion instead.