/    Sign up×
Community /Pin to ProfileBookmark

Related to Logout

Hello,

i am having chat page in which there is a [B]logout[/B] link which on clicking redirects to a logout page in which a status_flag is set to ‘0’ for that particular user who is getting logged out.

also, in that chat page , one of the right-side panel is showing the logged users (whose status of that status_flag are set to ‘1’)

the problem i am geting is when any particular user is not using that logout link to Logout instead he is just closing that window(i mean the browser window), then that status_flag remains set to ‘1’ , and it looks to other users that he is [B]Logged in[/B]….
So, what i want is how to make such an arrangement such that if that user closes that window then that status_flag is also set back to ‘0’

can u give me some suggession
thanks
-gaurav

to post a comment
PHP

10 Comments(s)

Copy linkTweet thisAlerts:
@NogDogJun 17.2006 — There's no way for the server to tell the difference between someone closing their browser window or just leaving a page from your site displayed on their browser. (Or if there is a way, it would require some sort of client-side technology which you might not be able to depend on each user having it available.) A typical way to display on-line users is to save the current time to a field in the database for each user whenever they access a page. Then the current users are displayed from a query that selects users where their access time compared to the current time is less than some arbitrary number of minutes.
Copy linkTweet thisAlerts:
@gaurav_095authorJun 17.2006 — ok thanks

its working
Copy linkTweet thisAlerts:
@bokehJun 17.2006 — The answer is to use appropriate technologies for whatever you are building. HTTP is an inappropriate technology for a chat program. The constant refreshes necessary to check for possible updates make it such.
Copy linkTweet thisAlerts:
@cridleyJul 10.2006 — Hi, on a very similar topic, I'm creating a php database app which locks records against a user id whilst the user is viewing/editing said record. When user stops viewing, the record gets unlocked, when the user logs off, all records with his id get unlocked. What I need is a way to unlock said records when user exits without logging off, easy with most standalone non-browser driven apps which have clearup functions.

Is there maybe a scheduled operation that mySQL server can perform to check all users not active for x minutes automatically get logged off? I'll be storing logged on users in a table, something like user_ID, timelogged_on, IP_address, but if the user just closes the browser then the entry stays and all locked records stay locked.

This site (webdeveloper.com) for example, logs peops off after some time inactive. This must be done server side, but how?

Sorry about this, I'm just not sure how to go about it, so thanks in advance for any ideas or pointer towards any tutorials in this particular area.
Copy linkTweet thisAlerts:
@sridhar_423Jul 10.2006 — cant this be done using AJAX.. keeping the point "HTTP inappropriate for Chatting" aside.

onbeforeunload=function(){

Ajax stuff to update the User status to Offline

}
Copy linkTweet thisAlerts:
@bokehJul 10.2006 — You don't need to schedule anything. Just run your clean up code before each and every time the table is accessed.

[CODE]UPDATE $tablename
SET active = 0
WHERE $last_access < '$ten_minutes_ago'[/CODE]
Copy linkTweet thisAlerts:
@bokehJul 10.2006 — cant this be done using AJAX.[/QUOTE]Not reliably no!
Copy linkTweet thisAlerts:
@cridleyJul 10.2006 — sorry, I'm getting there slowly. should I update lastaccess each time a user makes any change in the database? ok can do.

Then also perform a check for all users at the same time as the above and log them off if necessary? (ie delete all locked records statuses for all users that have timed out - everytime a query is made?)

Thanks again, sorry for not being on the ball with this one...
Copy linkTweet thisAlerts:
@bokehJul 10.2006 — lastaccess each time a user makes any change in the database?[/QUOTE]When they last access the website, the page, or the table. Do whichever suits your goal best.
Copy linkTweet thisAlerts:
@cridleyJul 10.2006 — Thanks a lot will give a bit of though and give it a try.
×

Success!

Help @gaurav_095 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...