* THIS BIT IS FIXED IN STONE *
We have 1 webpage with 3 iFrames inside. All iFrames point to the same script but pass different querytring values. E.g.
- Webpage: mypage.html
- iFrame1: script.php?x=1
- iFrame2: script.php?x=2
- iFrame3: script.php?x=3
So when a user visits the webpage, they are calling script.php 3 times.
* QUESTION *
Is there a way to get script.php to be aware that it is being called 3 times by the same client/browser/person and then order or queue those calls? E.g.
- 1st time – set an ID and save to session
- 2nd time – get the ID from the session and use it
- 3rd time – get the ID from the session and use it
What’s happening to me at the moment is that script.php is being executed 3 times at the same time and each iFrame is setting it’s own ID. I’d like them all to use the same ID.
Hope that makes sense?
Thanks in advance for you help.
Ryan
You need to track users with cookie, or IP address to know that it is the same user. And if you “save to session” then you HAVE TO have cookies used already (otherwise it is not really a session), so basically before you create new ID you just have to check if ID is not stored in session already. If not, generate it and use and also store in session.
EDIT: You can use PHPSESSIONID for the purpose, as it will be the same as long as session is maintained. I suspect the only thing you need to tweak is ID generation in your code, to ensure ID was not already generated. If not, generate and save in session so further calls will not generate it again but return value stored in session. But please keep in mind that you may face concurrency here and 2nd request may arrive before your 1st is completed (this both will generate new IDs), so you shall either use locking to prevent this, or use PHPSESSIONID value if that suffices.