Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

logout probem

Status
Not open for further replies.

martinb7

Programmer
Jan 5, 2003
235
0
0
GB
hi, i have a login system so that when someone logs in it updates a mysql table to 'yes' instead of 'no'. and when you log out it does the opposite. That all works fine.

my problem is that if they shut the window, it will still be logged in as yes, how wud i make it change to no if the window is shut?

Any ideas??

Thanx

Martin

 
You can't make it change to no if the browser is shut.

Keep in mind that a web app is a discontinuous set of individual conversations. Once a web page is streamed to a browser, the conversation that included that stream ends.

If a user closes the browser, there is no connection between the server and the browser. It's just so happens that the browser is displaying a copy of the data sent by the server.

You can try some JavaScript or VBScript to invoke a page on browser shutdown, but that's very browser-dependent and not guaranteed to work.

I recommend that you implement some kind of garbage collection. Put a time-date stamp column on your user table and update the user's record every time he does something. Then have a script, invoked by your site's script pages, set the login status to "n" for all users that haven't done anything over a certain amount of time.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Keep in mind, however, this is not a deterministic way of locking out a user. A user can dump his cookie store (or in some browsers, delete any single cookie) any time he wants.

I which case, your site will let him vote again. With PHP and CURL I could write a script that would vote in your poll 10000 times an hour.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top