|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
How to update user login status upon close browser
Hi guys, sorry for posting this kind of petty questions, but i'm really facing problem with this,
is there a way for me to automatically logs out the user from the database when the user closes his browser? or is there a way to work around it? the only success ive gotten so far is by timing out the user upon inactivity for n period. any help will be useful thanks. |
|
#2
|
||||
|
||||
|
Here is a solution
http://www.bennadel.com/blog/1131-Ask-Ben-Ending-ColdFusion-Session-When-User-Closes-Browser.htm google is your friend ![]() |
|
#3
|
|||
|
|||
|
yeah i've checked out the link previously and have implemented session. But that only fixes the function part.
here, let me explain more on what i wanna do Code:
If cookie isDefined if cookie/session/etc values are the same if loginstatus is false then login is approved else, send user back out else if loginstatus is false then login is approved else, if the user closes the window without logging out then login status is still true, and since its still true. function(check)<-- i can't figure out on how to do this, just having session variables is not enough. else send user out Else Force User To Enable Cookie Before Attempting Log In |
|
#4
|
|||
|
|||
|
You can't reliably do this. HTTP is stateless, and when the user closes their browser, there is no reliable way to tell the server anything. There are probably JavaScript hacks floating around out there that will try to trigger some last-minute notification to the server, but those are not reliable.
The best you can do is set up per-session cookies. When the user closes their browser, they have lost their connection to that session. At that point, after whatever session timeout period you have set, the session will end (and OnSessionEnd() will be called if you are using Application.cfc). But other than this, there is nothing you can do, it's a result of the stateless nature of HTTP.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#5
|
|||
|
|||
|
To restate this, the only reliable way to end a user's session is if they press a logout button. Unless they do that, you have to wait for the session to expire.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > How to update user login status upon close browser |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|