I’d like to avoid the possibility to open two application windows (or tabs). It is, if my app (LAMP+Javascript) is installed on http://www.domain.com and the user is browsing the page http://www.domain.com/user/ he/she cannot open another window like http://www.domain.com/system/. If he/she opens another window, the application should show an error message.
Is that possible?
For curious people: I need this behaviour because my app uses some session data to identify sequences of actions. If the user opens a new window on the same browser, normally everything is right, but if he/she starts a new sequence, the previous one (in the other window) will be lost.
While it is correct what all others said here that you cannot prevent someone from opening your website twice, there might be a workaround for you. Note that this is not a 100% solution and will require you to develop further code based on this.
As far as I understand you have the following problems:
However – you could use LSO – Local Shared Objects to accomplish this. These are Flash based cookie similar data pieces stored at the client’s side. AND THEY ARE CROSS-BROWSER & CROSS-DOMAIN COMPATIBLE. You can find a nice library called EVERCOOKIE for using them here.
By setting such a cookie you will be able to trace the user even if he opens a new window or even if he opens your page in a different browser, as far as the browsers share the same Flash installation etc.
Note that this will not prevent someone in opening two windows directly, but it enables you to send him to the same sequence state as he is in the other window for example.
You should also be aware that this is not a 100% solution. There will always be some trick to get around this, although I think normal users would not be able to get it…