• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Deleting sessions from memory in cf server

Guest
Jun 06, 2006 Jun 06, 2006

Copy link to clipboard

Copied

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?

TOPICS
Advanced techniques

Views

352

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 07, 2006 Jun 07, 2006

Copy link to clipboard

Copied

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>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 09, 2006 Jun 09, 2006

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 09, 2006 Jun 09, 2006

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 09, 2006 Jun 09, 2006

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 09, 2006 Jun 09, 2006

Copy link to clipboard

Copied

LATEST
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





Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation