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

How to call onSessionEnd Explicitly

Participant ,
Sep 22, 2010 Sep 22, 2010

Copy link to clipboard

Copied

Hi all,
I have a problem in Application.cfc .Please give some suggestions .

In  my Application.cfc I have created one onSessionEnd function where I am  creating log report of which session exists for how much time. It  works fine only when the session expires automatically but I want make a explicit call  to that function in my log out page.I had tried but it is showing some  error.Is it possible to explicitly call this function.

TOPICS
Builder

Views

1.6K

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
LEGEND ,
Sep 22, 2010 Sep 22, 2010

Copy link to clipboard

Copied

You shouldn't be wanting to call onSessionEnd() explicitly... it's an event handler designed to fire given a specific event.

However it's entirely reasonable for you to have another method which both your explicit logout code and onSessionEnd() calls.  So I recommend factoring-out this code that needs to be called by both onSessionEnd() and your own code into a separate method.

BTW: it would also help when you post something here saying "there's an error" (etc), for you to post the actual error.

--
Adam

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
Guide ,
Sep 22, 2010 Sep 22, 2010

Copy link to clipboard

Copied

Put something like this in your onRequestStart method:

<cfif structKeyExists(URL, 'end') >
    <cfset onSessionEnd() />
</cfif>

Then calling *any* page with ?end will end the session.

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
Participant ,
Sep 27, 2010 Sep 27, 2010

Copy link to clipboard

Copied

Hello friends,

     First of all sorry for the late response.

I think I have done that by the following code in the onSessionEnd().

<cfapplication

name="TeamManagementSystem"

clientmanagement="Yes"

applicationtimeout="#CreateTimeSpan(0, 0, 20, 0)#"

sessionmanagement="Yes"

sessiontimeout="#CreateTimeSpan(0, 0, 0, 0)#" >

This code working fine for mu work.Thanks

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
Participant ,
Sep 29, 2010 Sep 29, 2010

Copy link to clipboard

Copied

I have tried it and suceed by using this solution--

<cffunction

name="onSessionEnd" output="false">

<cfargument name = "sessionScope" required=true/>

<cfargument name = "applicationScope" required=true/>

<cfset var sessionLength = TimeFormat(Now() - sessionScope.started, "H:mm:ss")>

<cflock name="AppLock" timeout="5" type="Exclusive">

<cfset arguments.applicationScope.sessions = arguments.applicationScope.sessions - 1>

</cflock>

<cflog file="#this.name#" type="Information"

text=

"Session #arguments.sessionScope.sessionid# ended.Length: #sessionLength# Active sessions: #arguments.applicationScope.sessions#">

<cfscript>

StructClear(#arguments.sessionScope#);

</cfscript>

<cfapplication

name="#this.name#"

clientmanagement="Yes"

applicationtimeout="#CreateTimeSpan(0, 0, 20, 0)#"

sessionmanagement="Yes"

sessiontimeout="#CreateTimeSpan(0, 0, 0, 0)#" >

</cffunction>

You can call this method explicitly when ever required.Thanks

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
New Here ,
Feb 27, 2011 Feb 27, 2011

Copy link to clipboard

Copied

Hi Upen@Roul ,

I got through your lines, but before I could suggest you some thing on this issue I must like to watch the error that you got while calling 'onSessionEnd' method. I guess the issue might be some thing like the method is not defined. If this is the issue, then the most probable solution to this is you must call the methods as Application.method_name. Hope fully this will fix your issue. If you have some other issues, then please mention the error message.

Thanks

Dipak

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
Participant ,
Feb 27, 2011 Feb 27, 2011

Copy link to clipboard

Copied

LATEST

Hi Dipak,

I had written this post a long time ago.So now I can't say you the particular error message .But that time my problem was to expire a session before the expiration of it's time limit .So by using the following piece of code you can do that.

<cfapplication

name="#this.name#"

clientmanagement="Yes"

applicationtimeout="#CreateTimeSpan(0, 0, 20, 0)#"

sessionmanagement="Yes"

sessiontimeout="#CreateTimeSpan(0, 0, 0, 0)#" />

Here we are setting the session time out value as 0 sec.

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