Jump to content


Photo

Limit users to 1 active login


  • Please log in to reply
22 replies to this topic

#21 lead2gold

lead2gold
  • Members
  • PipPipPip
  • Advanced Member
  • 164 posts
  • LocationOttawa, On

Posted 09 August 2006 - 04:03 PM

you could always stamp breadcrumbs in the session file.

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.

#22 DarkReaper

DarkReaper
  • Members
  • PipPipPip
  • Advanced Member
  • 36 posts

Posted 09 August 2006 - 04:08 PM

i understand your idea but how can i set the key if i cant carry the data on a separate storage for each window. + i dont have a submit/post on every page. Thats why i am asking is there a way to carry this key via the browsers headers or some other way

#23 lead2gold

lead2gold
  • Members
  • PipPipPip
  • Advanced Member
  • 164 posts
  • LocationOttawa, On

Posted 09 August 2006 - 04:55 PM

Well, you only write /check a key on every submit.
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