2 Replies Latest reply on Oct 11, 2006 9:04 PM by Newsgroup_User

    Logging users out after certain period

    Level 7
      Hi,

      Im having trouble creating a basic timer that throws users out to the logout
      page after a certain amount of inactivity, Its set to one minute at the
      moment. I want to place this code on the top of certain pages. Im having all
      sorts of trouble with the conditional code and the functions.

      At the moment the page executes but my conditional code is ignored. I cant
      seem to validate the client.timeout variable. I've tried the isDate
      function that also hasnt worked for me. The logic is that when users request
      a page the timeout variable is compared to the current time.

      Can anyone help please.


      <!----See if the client variable had been set from a previous load of the
      page---->
      <cfif isDefined("client.timeout")>

      <!-----If variable isdefined calculate how long since users last
      activity----->

      <cfif datecompare(client.timeout, now(), n) EQ -1>
      send away to logout page and kill cfid and cftoken
      cookie<cfabort>
      <cfelse>
      keep the user active
      </cfif>
      </cfif>

      <cfset countdown=#CreateODBCDateTime(now())#>

      <cfset client.timeout= #countdown# + #CreateTimeSpan(0, 0, 1, 0)#>
      <cfset client.timeout= #CreateODBCDateTime(client.timeout)#>

      <!------Test Output----->
      <cfoutput>#countdown#</cfoutput><br />
      <cfoutput>#client.timeout#</cfoutput><br />
      <cfoutput>#datediff("n", client.timeout, countdown)#
      </cfoutput>


        • 1. Re: Logging users out after certain period
          azadisaryev Level 1
          why don't you use session management in yuor application.cfm/cfc for this? you can set sessiontimeout parameter there.
          • 2. Re: Logging users out after certain period
            Level 7
            Yeah i was confused about that. does the sessiontimeout kill my cookies
            thoughe cause oi have the following in the login page.

            application.cfm page
            <CFAPPLICATION NAME="xxxxx" SESSIONMANAGEMENT="YES" clientmanagement="yes"
            sessiontimeout="#CreateTimeSpan(0,0,30,0)#" SETCLIENTCOOKIES="NO">


            login.cfm page
            <!--- CF will not set the client cookies automatically, so set them manually
            as per-session cookies --->
            <cfif not IsDefined("Cookie.CFID")>
            <CFLOCK SCOPE="SESSION" TYPE="READONLY" TIMEOUT="5">
            <CFCOOKIE NAME="CFID" VALUE="#SESSION.CFID#">
            <CFCOOKIE NAME="CFTOKEN" VALUE="#SESSION.CFTOKEN#">
            </CFLOCK>
            </cfif>


            logout.cfm page
            <!---Code to delete existing session CFIF and CFTOKENS--->

            <CFCOOKIE NAME="CFID" VALUE="#CFID#" EXPIRES="NOW">
            <CFCOOKIE NAME="CFTOKEN" VALUE="#CFTOKEN#" EXPIRES="NOW">





            "Sabaidee" <webforumsuser@macromedia.com> wrote in message
            news:egk6t8$rnd$1@forums.macromedia.com...
            > why don't you use session management in yuor application.cfm/cfc for this?
            > you can set sessiontimeout parameter there.