Jump to content

File Lock?


stylusrose

Recommended Posts

I was trying to write a script that outputs to a file. the problem is, I don't want more than one user to be able to run that script at time.

 

I know, mysql would probably be a better idea. But I'm just tinkering around with ideas.

 

So, is there anyway to prevent a user to access a script whilst it is in use?

Link to comment
https://forums.phpfreaks.com/topic/103386-file-lock/
Share on other sites

you can use mysql and then an if statement like

if($inuse=="yes") {
echo"Sorry the file is currently in use, please try again later";
}
else
{
//DISPLAY DATA HERE
}

 

And then have like a cron job script run to where if the last time it was used was 10 mins ago or so, it clears the mysql, just incase the user exits his/her browser, and have a link to exit, so that way it clears the data.

 

I know it sounds kinda confusing but I haven't been to sleep yet, so hope this helps

Link to comment
https://forums.phpfreaks.com/topic/103386-file-lock/#findComment-529440
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.