nakatakyo — 2002-02-25T05:29:12-05:00 — #1
is there possible that i can detect the user click the refresh button in the browser???:bawling:
marcusjt — 2002-02-25T10:15:57-05:00 — #2
You can't detect the button being pressed, but you can catch the page being unloaded (i.e. when the user navigates to another page or refeshes). Would that help?
nakatakyo — 2002-02-25T21:41:52-05:00 — #3
thanks for replying
but this one is not the one i want, now the situation is when the user click refresh or leave my website and go to other web site or close window that time i want to update some data in database so how i detect this few thing???
weirdbeardmt — 2002-02-26T05:35:38-05:00 — #4
If you are trying to catch when people leave your site, then use onUnload.
marcusjt — 2002-02-26T09:27:37-05:00 — #5
onUnload and onBeforeUnload are virtually identical, but subtly different (look them up). In this case, either will do, so fine. However Nakatakyo, the point is that what you are asking for cannot be done, so these suggestions are the closest we can come to providing a solution.
If you explain what you are trying to do a little more I might be able to think of a different approach to your problem.
marcusjt — 2002-02-26T09:36:47-05:00 — #6
Ah, just re-read your last post. You want to trigger a server-side action when the client changes/refreshes the URL?
Then use the onBeforeUnload / onUnload event to call a function which uses JSRS (http://www.ashleyit.com/rs/main.htm) to call the desired script on the server. In this script you can then so whatever you want.
An alternative would be to use the server-side session end event (ASP has it, so presumable PHP has it too) to detect when the visitor's session has expired and then execute the tasks that you want.
marcusjt — 2002-02-26T09:40:44-05:00 — #7
However my two previous suggestions (particularly the latter) would be far easier to implement.
nakatakyo — 2002-02-26T22:32:21-05:00 — #8
thanks for M@rco and weirdbeardmt for replying me
i think i need to tell u all more cleary about my problem
in my website i dont want two same user login at the same time so i save some info inside database to detect it and i always want to know whether the user have log out or not.so the user logout got few way
one is prober logout
two is close the window
three is move to other side
one is no problem to me and two and three also no problem (i use onbeforeunload to detect close window and move to other side) but one problem is when i refresh the page that time the onbeforeunload also detect the action and update my database set the user log out so i need to find the solution to detect the refresh
so got any sugggestion or solution to solve this problem?
marcusjt — 2002-02-27T05:14:41-05:00 — #9
Is your site written in ASP or PHP (or something else)?
I have a cunning plan.....! (c)Baldrick
nakatakyo — 2002-02-27T23:14:58-05:00 — #10
i'm using php to develop my site
marcusjt — 2002-02-28T11:56:05-05:00 — #11
Here's the plan:
At the top of every script, set the session timeout to 30mins or whatever you want it to be normally.
Then, use the onunload or onbeforeunload events (in conjuction with the JSRS library that I gave the URL for earlier) to call a script which sets the session timeout to one minute or so.
You then need to catch the session expiry event (however you do it in PHP) and call your log out code when it occurs.
Thus, if the user is leaving the site (by closing the window, or navigating to another site), then his session expires one minute later. If he is only refreshing the page, then as soon as the page is called, the session timeout is reset to its normal value, and he stays logged in!
nakatakyo — 2002-02-28T22:36:42-05:00 — #12
how i detect the session is expiry after the user leave the site or close the window
and actually i just can catch a little bit wat u say but i think after i know how to catch the session then is ok already
however thanks a lot for helping
marcusjt — 2002-03-01T05:49:44-05:00 — #13
In ASP, it's an event handler that you place in theGLOBAL.ASA file. It should be something similar in PHP, but I don't program in PHP. I had a quick search, and this should tell you everything you need to know:
marcusjt — 2002-03-01T08:11:17-05:00 — #14
Was running late earlier. Just got back and had a better look at that link - PHP does not seem to have an equivalent to ASP's Session_OnEnd() event....
Any PHP coders know any different?
weirdbeardmt — 2002-03-01T08:50:47-05:00 — #15
I'm not entirely sure how you would use it, but it would be either [session unregister or [URL=http://www.php.net/manual/en/function.session-destroy.php]session destroy. I suppose technically (depending on what you are doing with it) you could use [URL=http://www.php.net/manual/en/function.session-write-close.php]session write close](http://www.php.net/manual/en/function.session-unregister.php).
maelstrom — 2002-03-01T16:27:25-05:00 — #16
Isn't the onbeforeunload handler only handler with IE. Last time I checked it was an IE specific handler (as most of the good ones are).
nakatakyo — 2002-03-01T23:35:16-05:00 — #17
so actually php support the method or not?
maybe i also go find some information and tell u, ok
anyways thanks all of u have answer my question
maelstrom — 2002-03-03T01:40:34-05:00 — #18
Originally posted by nakatakyo
[B]so actually php support the method or not?
maybe i also go find some information and tell u, ok
anyways thanks all of u have answer my question [/B]
marcusjt — 2002-03-03T09:31:07-05:00 — #19
I think you may be right about IE-only onBeforeUnload - use onUnload instead.
RE: PHP Session End
ASP code is executed linearly, but it does support four events which you can use to execute code when they are triggered. They are:
It would appear that PHP does not feature these vital events. This was a difference between the two language which I was unaware of - I had previously thought that both were equivalent in functionality in that there is nothing that can be done in one that cannot be done in the other. I now see that this is incorrect, the case in hand being one example. Are there any other "missing features" in PHP compared to ASP?
nakatakyo — 2002-03-04T00:12:47-05:00 — #20
so that mean php cannot support this method then mabe i need to think other way to handle the detect user logout or leave the site but however thanks to all have answer and help me
next page →