4

coldfusion.runtime.SessionTracker次のコードを使用して、現在ログインしているユーザーを監視するために ColdFusion 9を使用しています。

app = application.getApplicationSettings().name;
sessiontracker = createObject("java","coldfusion.runtime.SessionTracker");
sessionCollection = sessionTracker.getSessionCollection(app);

これは、現在アクティブなすべてのセッションの とセッションの変数structを返します。jsessionid

jsessionidユーザーを効果的に強制的にログアウトさせた場合、セッションを強制的に終了させることはできますか?

ありがとう、

リチャード

4

2 に答える 2

2

したがって、ユーザーがログインするとuser、セッションに構造を設定して、ログイン状態を削除します。I を使用sessionTrackerすると、特定のユーザーのセッションを取得userして、現在のセッションの構造を削除できます。

app = application.getApplicationSettings().name;
sessiontracker = createObject("java","coldfusion.runtime.SessionTracker");
sessionCollection = sessionTracker.getSessionCollection(app);

userSession = sessiontracker.getSession(app, sessionID));

structDelete(userSession, "user");

これが最善の方法かどうかはわかりませんが、私にとってはうまくいくようです。それが人々を助けることを願っています。

于 2013-02-09T15:39:18.713 に答える
0

application.cfc で onSessionEnd を使用してみましたか? ログアウト プロセスで手動で起動することも、ユーザーがブラウザを閉じたり、うまく機能するものを閉じたりすると自動的に起動することもできるためです。これが私たちの使い方です。

application.cfc では、onSessionEnd を起動し、application.cfc にもある logout 関数を起動し、すべてのクリーンアップとロギングを行います。

<cffunction name="OnSessionEnd" access="public" returntype="void"
                 output="false" hint="Fires when the session is terminated.">
        <cfargument name="SessionScope" type="struct" required="true" />
        <cfargument name="ApplicationScope" type="struct"
                                  required="false" default="#StructNew()#" />
        <cfargument name="timedOut" type="boolean" required="false" default="true">
                <cfinvoke thisSessionScope="#SessionScope#"
                      timedOut="#arguments.timedOut#" method="logout">
                </cfinvoke>
            <cfset structClear(arguments.sessionScope) >
         <!--- Return out. --->
        <cfreturn />
    </cffunction>

お役に立てれば

于 2013-02-03T01:25:41.973 に答える