tweekerbythespeeker
Programmer
This is more of a general consideration and query to all who know more than I. Heres the deal...
1. a session is created for a unique user when they log on to an online application
2. When they log on, a value is changed from '0' to '1' in a DB (upon this is based a "whos online search"). So obviously in a perfect world, when they are finish(and or session times out), the value is changed back to '0'. This is easy if they click "log-off". In that case I just use the "structure(clear)" and a simple UPDATE query to achieve the desired result. I can also achieve the desired results if the user's session timesout while ON MY SITE with some "if thens", and a cookie read in on my "application.cfm" page.
The code on my application.cfm page is below.........
3. 2 situations need to be accounted for though:
- when the user does not log off, browses to another site and their session times out. This is ONLY ACTUALIZED UPON RETURN... if the user goes astray and timesout while gone... they are still considered online while at different websites. The value is only changed back to '0' when they return. Only THEN is the "application.cfm" page able to check out the situation and act accordingly on the lack of values for 'session.loggedin' and 'cookie.test' (this cookie is created at login and only contains the user's unique ID for the changing of the value "prf_online")
-this is true for the closing of the browser part too. If they close the browser... It is working in theory, but not actualized until they go back and application.cfm is able to do its thang.
Does anyone have light to shed? I feel like there must be a more efficient way of doing a "Whos online search"....?
thnks -- joe
-------------------------------------------------------
<!-- basically saying, if they have logged on
(hence the cookie), and their sesh has expired
change the value and kill the cookie. this part
works well is they stay on the site and dont
browse away before timoeout-->
<cfif NOT isDefined('session.loggedin') AND isDefined('cookie.test')>
<cfquery name="updateVals" datasource="dudefinders">
UPDATE cs_tbl_profiles
SET prf_online= '0'
WHERE ID = #cookie.test#
</cfquery>
<cfcookie name="test" expires="now">
</cfif>
<!-- for browser closing -->
<cfif IsDefined("Cookie.CFID") AND IsDefined("Cookie.CFTOKEN")>
<cfset cfid_local = Cookie.CFID>
<cfset cftoken_local = Cookie.CFTOKEN>
<cfcookie name="CFID" value="#cfid_local#">
<cfcookie name="CFTOKEN" value="#cftoken_local#">
<!-- from above -->
<cfif NOT isDefined('session.loggedin') AND isDefined('cookie.test')>
<cfquery name="updateVals" datasource="dudefinders">
UPDATE cs_tbl_profiles
SET prf_online= '0'
WHERE ID = #cookie.test#
</cfquery>
<cfcookie name="test" expires="now">
</cfif>
</cfif>
1. a session is created for a unique user when they log on to an online application
2. When they log on, a value is changed from '0' to '1' in a DB (upon this is based a "whos online search"). So obviously in a perfect world, when they are finish(and or session times out), the value is changed back to '0'. This is easy if they click "log-off". In that case I just use the "structure(clear)" and a simple UPDATE query to achieve the desired result. I can also achieve the desired results if the user's session timesout while ON MY SITE with some "if thens", and a cookie read in on my "application.cfm" page.
The code on my application.cfm page is below.........
3. 2 situations need to be accounted for though:
- when the user does not log off, browses to another site and their session times out. This is ONLY ACTUALIZED UPON RETURN... if the user goes astray and timesout while gone... they are still considered online while at different websites. The value is only changed back to '0' when they return. Only THEN is the "application.cfm" page able to check out the situation and act accordingly on the lack of values for 'session.loggedin' and 'cookie.test' (this cookie is created at login and only contains the user's unique ID for the changing of the value "prf_online")
-this is true for the closing of the browser part too. If they close the browser... It is working in theory, but not actualized until they go back and application.cfm is able to do its thang.
Does anyone have light to shed? I feel like there must be a more efficient way of doing a "Whos online search"....?
thnks -- joe
-------------------------------------------------------
<!-- basically saying, if they have logged on
(hence the cookie), and their sesh has expired
change the value and kill the cookie. this part
works well is they stay on the site and dont
browse away before timoeout-->
<cfif NOT isDefined('session.loggedin') AND isDefined('cookie.test')>
<cfquery name="updateVals" datasource="dudefinders">
UPDATE cs_tbl_profiles
SET prf_online= '0'
WHERE ID = #cookie.test#
</cfquery>
<cfcookie name="test" expires="now">
</cfif>
<!-- for browser closing -->
<cfif IsDefined("Cookie.CFID") AND IsDefined("Cookie.CFTOKEN")>
<cfset cfid_local = Cookie.CFID>
<cfset cftoken_local = Cookie.CFTOKEN>
<cfcookie name="CFID" value="#cfid_local#">
<cfcookie name="CFTOKEN" value="#cftoken_local#">
<!-- from above -->
<cfif NOT isDefined('session.loggedin') AND isDefined('cookie.test')>
<cfquery name="updateVals" datasource="dudefinders">
UPDATE cs_tbl_profiles
SET prf_online= '0'
WHERE ID = #cookie.test#
</cfquery>
<cfcookie name="test" expires="now">
</cfif>
</cfif>