0

I want to understand how I can difference two request which were rised at the same time??

for example:User A want to buy some product and this product has price for example 100$, this User has only 110$ and increase price to 110$ but at the same time another User B increases price too, and his request postback faster than User A, because A has Slow internet...When A's request at last reaches to the server price is already changed and it's 110$ because of B and after that it will be 120$...


sorry for my English :(

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by madmital
0

Alongside the price you could send a timestamp with the request.
In database you would have columns to hold:
Product name, current price, time of last price/bid, etc.

User A loads the product page.
You show him the current price, but also saves the "time of last price/bid" to a hidden field on the page.
When user A increases the bid from 100 to 110, you would send both the price increase and the timestamp from the hidden field to the server.
On the server check if the timestamp that just came from the user is equal to the one that's already in the database. If it is, the bid hasn't been changed since User A loaded the page. If it is not the same, that means User B, User C or User x has made a bid in the "time window" between User A loaded the page and the time he/she submitted a new bid.

I a multi user environment timestamping is always a good idea.
Makes sense?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.