Block concurrent logins
Hi, I'm trying to block concurrent logins.
What I've done so far:
I've added a new column in the login table called logged, which holds values 1 or 0
When a user logs in, it updates the value to 1.
It will login user's who's status is 0.
When users click logout, it changes the status to 0
The Problem
If the user just closes the browser, how is the system supposed to know that the user's logged status needs to be 0?
I reasoned that the onSessionEnd method would do the trick. When the session expires, it simply updates the database for that user to 0. So I put in the code, but nothing.
<cffunction name="onSessionEnd" returnType="void">
<cfquery name="updateloggedstatus" datasource="datadsn">
UPDATE usermanagerlogin
SET logged = <cfqueryparam cfsqltype="CF_SQL_INTEGER" value="0">
WHERE userid = <cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="user1">
</cfquery>
</cffunction>
In another application, I have used the onSessionEnd method succesully. I have used it to delete the items that were in the shopping cart, which were in the database, who's order was not complete.
<cffunction name="onSessionEnd" returnType="void">
<cfargument name="SessionScope" required=True/>
<cfquery name="deletesessionendticket" datasource="tickdsn">
DELETE FROM tbltick
WHERE oid = '#Arguments.SessionScope.oid#'
AND ordered = <cfqueryparam cfsqltype="CF_SQL_INTEGER" value="0">
</cfquery>
</cffunction>
The difference between the two is that the new app is being developed in cf9, while the older app was built in cf8
In the current app, the session does end succesfully, in that it asks me to login, but the onSessionEnd method is not executed.
Any Ideas?
Much appreciated.
