Reputation: 2203
I have created a web page but i want to restrict only one instance of the page should be running at all times. The scenarios are given as below.
Additional Details : I have a database, user authentication.
Tried So Far : Set a flag in DB-->> This method how do i redirect the user back to the page which is already opened.
Any ideas to implement this.?
Thanks in Advance for your opinions and suggestions.
Upvotes: 1
Views: 186
Reputation: 10400
You should consider using cookies for this. Create a session-long cookie upon opening of the window and destroy it upon closing of the window. If a cookie already exists, you know the window is already open.
This of course relies on javascript and is easily got round. You can not use a server-side solution because it would be impossible to catch the closing of the browser window in order to clear the cookie.
Personally, I wouldn't try and restrict the opening of multiple windows but restrict the functionality available in each window. This approach would be much easier to control using a server-side approach, e.g. events fired in the window can be validated server-side.
Upvotes: 1
Reputation: 24729
Perhaps you should use a cookie which expires when the user closes the browser. However, all browser instances may need to be closed.
Upvotes: 1