Hi, I am working on a chat program.
When a user logs in, a value in the database is set to 1 (online), and when he/she logs out it is set to 0 (offline).
The problem is, when the user exits the browser, naturally the value is still set to 1.
I was wondering if it is possible using AJAX or otherwise to update the database on the event of browser close?
I have tried onbodyunload in the body tags pointing to a file with a JavaScript function containing the PHP code (query to update the field) but cant get it to work.
If anybody has any advice, please help me it is driving me mad and is the biggest problem standing in my way to get the app to work...thanks you very much in advance for any replies :)
georgeee123
0
Newbie Poster
Recommended Answers
Jump to PostYou might try onbeforeunload. MSDN on event
Jump to PostYes using AJAX is possible and I've done this before. Try the Javascript
onunload()
event and link that to your AJAX.I've got it to work in the past. If you still have problems please let me know.
All 7 Replies
scrappedcola
11
Posting Whiz in Training
sudeepjd
19
Junior Poster
georgeee123
0
Newbie Poster
sudeepjd
19
Junior Poster
georgeee123
0
Newbie Poster
scrappedcola
11
Posting Whiz in Training
georgeee123
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.