JUSTICE
asked on
I would like to delete an entire session. Cflogout simply ends the session, but the variables remain on the server.
Here is my code I am using to view active sessions (basically shows a table of all users currently logged in)
<!--- Dump all session scopes --->
<table width="95%" align="center" cellspacing="0" cellpadding="0" bgcolor="#EBE9E9">
<TR bgcolor="#999999">
<TD align="left" valign="top"><img src="../images/topleft.gif "></TD>
<TD colspan="5" align="center"><B>Currentl y Logged In Users</B> <I>(Click to log user out)</I></TD>
<td align="right" valign="top"><img src="../images/topright.gi f"></td>
</TR>
<TR>
<TD> </TD>
<TD><B>Cust Code</B></TD>
<TD><B>User Name</B></TD>
<TD><B>Real Name</B></TD>
<TD><B>Login Date</B></TD>
<TD><B>IP</B></TD>
<TD> </TD>
</TR>
<cfscript>
session.test = true;
tracker = createObject("java", "coldfusion.runtime.Sessio nTracker") ;
mySession = tracker.getSessionCollecti on( application.applicationNam e );
for (keyname in mySession) {
WriteOutput("<TR onclick=""parent.Action.lo cation.hre f = 'action.cfm?ToDo=KillSessi on&Session =" & keyname & "';"" onMouseover=""this.style.b ackgroundC olor='##FF 9999';"" onMouseout=""this.style.ba ckgroundCo lor='##EBE 9E9';"" style=""cursor:pointer; background-color : ##EBE9E9;""><TD> </TD ><TD>" & mySession[keyname].custcod e & "</TD><TD>" & mySession[keyname].usernam e & "</TD><TD>" & mySession[keyname].name & "</TD><TD>" & DateFormat(mySession[keyna me].lastlo gin, "MM/DD/YYYY") & " " & TimeFormat(mySession[keyna me].lastlo gin, "HH:MM") & "</TD><TD>" & mySession[keyname].ip & "</TD><TD> </TD></TR> ");
}
</cfscript>
</table>
On my page action.cfm, for the ToDo='KillSession', I want to be able to delete the entire structure for the given users session.
My application name is 'Secure', and the key looks like this: secure_8430187081109749702 8343
My current code looks like this: But it appears to do nothing at all, not even error out:
<cfcase value="KillSession">
Deleting session <cfoutput>#URL.Session#</c foutput><B R><cfflush >
<cfset a = StructDelete(session, URL.Session)>
Done.<cfflush>
</cfcase>
Can anyone tell me what I am doing wrong???
<!--- Dump all session scopes --->
<table width="95%" align="center" cellspacing="0" cellpadding="0" bgcolor="#EBE9E9">
<TR bgcolor="#999999">
<TD align="left" valign="top"><img src="../images/topleft.gif
<TD colspan="5" align="center"><B>Currentl
<td align="right" valign="top"><img src="../images/topright.gi
</TR>
<TR>
<TD> </TD>
<TD><B>Cust Code</B></TD>
<TD><B>User Name</B></TD>
<TD><B>Real Name</B></TD>
<TD><B>Login Date</B></TD>
<TD><B>IP</B></TD>
<TD> </TD>
</TR>
<cfscript>
session.test = true;
tracker = createObject("java", "coldfusion.runtime.Sessio
mySession = tracker.getSessionCollecti
for (keyname in mySession) {
WriteOutput("<TR onclick=""parent.Action.lo
}
</cfscript>
</table>
On my page action.cfm, for the ToDo='KillSession', I want to be able to delete the entire structure for the given users session.
My application name is 'Secure', and the key looks like this: secure_8430187081109749702
My current code looks like this: But it appears to do nothing at all, not even error out:
<cfcase value="KillSession">
Deleting session <cfoutput>#URL.Session#</c
<cfset a = StructDelete(session, URL.Session)>
Done.<cfflush>
</cfcase>
Can anyone tell me what I am doing wrong???
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
referance : http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/functa90.htm#wp2978386
ASKER
When I do a StructClear, as it says on Livedocs, it leaves a structure out there with the session key, and it has no variables. Then, when I try to display all sessions, it errors because the Username variable no longer exists. How do I delete the root structure / key??
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yes, basically I am trying to force a cflogout for a given user.
Is there any way to <cflogout> for a passed user name?
Is there any way to <cflogout> for a passed user name?
I am sorry. But did you say yes to this question "Are you trying to delete the users current session?"
if so I should explained a little more
Are you trying to delete the users current session that COldFusion assigns to the user?
If so you can not do this while they are still on a cfm page on your site.
if so I should explained a little more
Are you trying to delete the users current session that COldFusion assigns to the user?
If so you can not do this while they are still on a cfm page on your site.
ASKER
OK, I think I am just going to add a bit to my application page that will check a SQL flag.
If set to 1, then do a <cflogout> and re-set flag to 0.
Its a bit more of a pain, but it should work. :)
Thanks all!
If set to 1, then do a <cflogout> and re-set flag to 0.
Its a bit more of a pain, but it should work. :)
Thanks all!
Glad we could help
wonderful!