Limit users to 1 active login
Posted 09 August 2006 - 04:03 PM
Each time a user does an action store an md5(time()+$key); Every action one takes, matches the current key and then the page is submitted. On the submit the key is changed.
In the event that the user ever had 2 windows open, his second window is uselsess now as it has a different key. Anything submitted there won't be saved.
you only preform the transaction if the keys match. On every match, the transaction is preformed and the key is changed.
Posted 09 August 2006 - 04:08 PM
Posted 09 August 2006 - 04:55 PM
So if they are doing a database transaction.
Then in each form, you store the last key in <input type="hidden" value=<?=$_SESSION['key']?> />
It doesn't matter how many windows anyone opens, because after the submit on 1 screen, the keys on all the other windows (will reference the old key) and will no longer be valid.
Upon each submit, you willl refresh the $_SESSION['key'] value.
After each submit, you must check $_POST['key'] to ensure that it is equal to $_SESSION['key']
Preform your sql, and change the $_SESSION['key']
The end result is someone who can have as many windows open as they want, But they will only be able to sequentially preform 1 task after another. the key acts as sort of a mutex/semaphore
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users