Someone can help me
close button in browser
Moderator: General Moderators
close button in browser
i want use the function to detect the close button in browser. If user click the close button without logout, i want to foce the user to logout.
Someone can help me
Someone can help me
- greenhorn666
- Forum Commoner
- Posts: 87
- Joined: Thu Aug 14, 2003 7:14 am
- Location: Brussels, Belgium
Why would you want to do this?
Besides this is not PHP code, but client side JavaScript...
If you want to force the user to logout, you might rely on the cookie specs:
[php_man]setcookie[/php_man]
Besides this is not PHP code, but client side JavaScript...
If you want to force the user to logout, you might rely on the cookie specs:
[php_man]setcookie[/php_man]
But, as you will reply, I know: WHEN THE BROWSER CLOSES, not the windowbool setcookie ( string name [, string value [, int expire [, string path [, string domain [, int secure]]]]])
<!-- snip -->
expire: If not set, the cookie will expire at the end of the session (when the browser closes).
<!-- snip -->
i am using session
sorry, i am using session to store data.
can you tell me how to empty the session if the window close.
because i use session to check the idle time, so i have to empty the session immediately after user close the window.
can you tell me how to empty the session if the window close.
because i use session to check the idle time, so i have to empty the session immediately after user close the window.
- greenhorn666
- Forum Commoner
- Posts: 87
- Joined: Thu Aug 14, 2003 7:14 am
- Location: Brussels, Belgium
Well Yes, but how do you link the session back to the browser?
Cookie most probably or URL rewrite?
In the second case, you loose the session as soon as you close the window (and I mean window!)
In the first case use the [php_man]session[/php_man]
Cookie most probably or URL rewrite?
In the second case, you loose the session as soon as you close the window (and I mean window!)
In the first case use the [php_man]session[/php_man]
session.cookie_lifetime integer
session.cookie_lifetime specifies the lifetime of the cookie in seconds which is sent to the browser. The value 0 means "until the browser is closed." Defaults to 0.See also session_get_cookie_params() and session_set_cookie_params().
This doesn't work on some browsers/OSes.greenhorn666 wrote:Well Yes, but how do you link the session back to the browser?
Cookie most probably or URL rewrite?
In the second case, you loose the session as soon as you close the window (and I mean window!)
In the first case use the [php_man]session[/php_man]session.cookie_lifetime integer
session.cookie_lifetime specifies the lifetime of the cookie in seconds which is sent to the browser. The value 0 means "until the browser is closed." Defaults to 0.See also session_get_cookie_params() and session_set_cookie_params().
I developed an intranet for a company, an poeple were logged out when they closed their browser apart from when they were on a MAC using IE 5.
Mark
close button
if i set session.cookie_lifetime to "1", what will it happen. becuase i havn't use this function before.
other method
so does it has another method to empty all sessions if user click the close button?
- greenhorn666
- Forum Commoner
- Posts: 87
- Joined: Thu Aug 14, 2003 7:14 am
- Location: Brussels, Belgium
You mean IE on Mac doesn't follow the Netscape cookies specs or it keeps a process running that never ends, hence the persistence?Bech100 wrote: This doesn't work on some browsers/OSes.
I developed an intranet for a company, an poeple were logged out when they closed their browser apart from when they were on a MAC using IE 5.
- greenhorn666
- Forum Commoner
- Posts: 87
- Joined: Thu Aug 14, 2003 7:14 am
- Location: Brussels, Belgium
- greenhorn666
- Forum Commoner
- Posts: 87
- Joined: Thu Aug 14, 2003 7:14 am
- Location: Brussels, Belgium
Re: other method
So the answer is, and for everyonetisa wrote:so does it has another method to empty all sessions if user click the close button?
Do not use a cookie to store the session, but rely on url rewrites!
Which is anyway safer, since you can force the user to have cookies enabled.