5 Replies Latest reply on Jun 9, 2006 12:10 PM by interarnett2

    Deleting sessions from memory in cf server

    interarnett2
      I am trying to build an admin function that will allow an administrator to be able to see any active user sessions in an application and forcefully remove them if necessary. I have been trying to get the code below working. Everything seems to work fine until I try and delete the key from the structure.

      Has anyone out there done this successfully? Is there something that I am missing here?

        • 1. Deleting sessions from memory in cf server
          BKBK Adobe Community Professional & MVP
          Revised:

          The comparison "if s eq form.sessionid" seems okay. But I would remove s instead from the sessions structure, thus

          <cfloop collection="#sessions#" item="s">
          <cfif s eq form.sessionid>
          <cfscript>
          StructDelete(Sessions, s, "True");
          </cfscript>
          </cfif>
          </cfloop>

          • 2. Re: Deleting sessions from memory in cf server
            interarnett2 Level 1
            Ok tried modifying my script with suggested code and it executes without error, but the session is not deleted... Any additional suggestions or clues?

            thanks

            Craig
            • 3. Re: Deleting sessions from memory in cf server
              BKBK Adobe Community Professional & MVP
              the session is not deleted
              hmm, interesting. I can confirm what you observed. However, the following identical code does work:

              <cfset t.x.s=1>
              <cfset t.x.t=2>
              <cfset t.x.u=3>
              <cfset t.x.v=4>
              <cfset t.y.s=5>
              <cfset t.y.t=6>
              <cfset t.y.u=7>
              <cfset t.y.v=8>
              <p>Before structdelete</p>
              <cfdump var="#t#">
              <cfset structdelete(t,"x")>
              <p>After structdelete(t,"x")</p>
              <cfdump var="#t#">

              I therefore suspect Coldfusion will not allow you to delete such system structures just like that. I'm looking into it.

              • 4. Re: Deleting sessions from memory in cf server
                JaredJBlackburn
                When you say that you're trying to write an app that lets an admin remove a session does that mean that you want to remove a variable from the session scope, clear the session scope of its contents, delete the session scope itself, or logout the user ?

                Deleting a variable from the session scope is possible with StructDelete(). Clearing the session scope of all its variables is possible with StructClear(). I don't believe it's possible to delete or remove the session scope for a user if sessions are turned on in the cfapplication tag. Forcing a user to loggout may be possible using the <cflogout> tag depending on how your system is set up.
                • 5. Re: Deleting sessions from memory in cf server
                  interarnett2 Level 1
                  I am trying to create a dashboard application that will work within any in house cf applications and funciton in the following manner.

                  1. Allow the application administrator to view users who are logged in to app with a session.

                  2. Allow the administrator a method to forcefully remove (or logout) user from application if necessary and clear memory on server.

                  I realize that I can get the session collection at two different levels using two different methods...
                  tracker.getSessionCollection(application.applicationName)

                  or

                  tracker.getSession(sessionid)

                  I am just having difficulty manipulating the values in the structs or deleting them.

                  I see an additional method of cleanup() in the object SessionTracker. Has anyone used this method?
                  Any snippets on how it works?

                  thanks

                  Craig