You could always just check the session scope for the account in question.
Whether the user has closed the browser and left their computer completely
or not doesn't really mean anything here. If the session is still there...
the account is technically logged in and there is really nothing you can do
but wait for it to time out since you don't know.

As for checking... the base of any login routine I write contains a basic
structure of info about the user to use throughout the session. Things like,
userid, username, emailaddress...
I store all of that info in a session structure like this when the user
jacks in ... 

session.myLoginSessionStructure.userID
session.myLoginSessionStructure.userName
session.myLoginSessionStructure.userEmailAddress
etc...

(actually I create a structure within session.myLoginSessionStructure called
'User' and store all the user specific info there but to keep it simple I'll
leave the extra struct out. I did do it this way at one time and it works
just as well.)

So if I want to check to see if a specific user's session exists by say...
their USERID... I would read each session.myLoginSessionStructure.userID
that is available and compare it to that UserID

<cfset sTracker = createObject("java","coldfusion.runtime.SessionTracker")
/>
<cfset allSessions =
sTracker.getSessionCollection(application.applicationName) />

<cfloop item="s" collection="allSessions">
        <cfif structKeyExists(allSessions[s], "myLoginSessionStructure") and
allSessions[s].myLoginSessionStructure['userID'] is UserIDToCheckFor>
                users sesison already exists
        <cfelse>
                users session does NOT already exist
        </cfif>
</cfloop>

..:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.
Bobby Hartsfield
http://acoderslife.com


-----Original Message-----
From: Paul Henderson [mailto:[EMAIL PROTECTED] 
Sent: Thursday, June 21, 2007 12:11 PM
To: CF-Talk
Subject: How to Prevent Simultaneous Login / Session Management

I know I can prevent any simultaneous logins by simply flagging the account
as "logged in" when a user logins. However, if the user closes the browser
or is disconnected without properly logging out, how would I go about
allowing them to log back in? Since as far as I know, the server and
database would therefore have no way of knowing the user disconnected and
would still see the user as logged in. I thought OnSessionEnd would do the
trick, but as was pointed out to me on this list OnSessionEnd only runs when
the session expires, not when the user disconnects. Any ideas are much
appreciated, thanks.

 

 

 





~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
CF 8 – Scorpio beta now available, 
easily build great internet experiences – Try it now on Labs
http://www.adobe.com/cfusion/entitlement/index.cfm?e=labs_adobecf8_beta

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:281812
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to