By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,557 Members | 1,406 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,557 IT Pros & Developers. It's quick & easy.

PHP Unique execution

P: 13
Hello,

Its possible to execute a php function one time for unique user ? or by user order ?

I mean, if two different user connected in the same time, is possible to execute a php function only for user 1, when finish then execute for user 2...

Some one know how ?
Dec 9 '11 #1

✓ answered by johny10151981

You can do a small trick.

At the beginning of the function create a file and lock the file. And delete the file at the end of the function execution.

Before the function create the file, check if the file is exists, if the file exists, delete the file, if the file is used by other function then the new execution wont be able to delete the file. rest is up to you ;)

Share this Question
Share on Google+
6 Replies


AutumnsDecay
100+
P: 170
What are you trying to accomplish with this script? A webpage doesn't see it as "user 1 came, and then user 2 came", it sees it as "user came". If 50 people go to a webpage, the webpage will not know that 50 people are there, it treats each one as unique.
Dec 9 '11 #2

100+
P: 1,059
You can do a small trick.

At the beginning of the function create a file and lock the file. And delete the file at the end of the function execution.

Before the function create the file, check if the file is exists, if the file exists, delete the file, if the file is used by other function then the new execution wont be able to delete the file. rest is up to you ;)
Dec 10 '11 #3

P: 78
web page means accesssing different people from different location. may be it is a single person or it may be thousands of people.Then is it possible to run individual function?.
Dec 12 '11 #4

100+
P: 1,059
Actually, what I have understood is OP Native language is not English.
That is why his question was little off-track.

He mean "Whether it is possible to run a function once at a time. i.e, in multi-threading system one function can be run more than once, but in this case op does not want his function to run while one instance is already running."
Dec 12 '11 #5

P: 13
yes johny10151981, exactly!
Dec 27 '11 #6

P: 13
because in this function my server connect to another server by an account, so the remote server don't allow multiple connections of one account...

So when an user run my function then my server connect, but if another user run this function in the same time then my server can't connect because it's already connected!

And the real problem is i can't connect one time and do many things.. so i most connect and disconnect for each user run my function.
Dec 27 '11 #7

Post your reply

Sign in to post your reply or Sign up for a free account.