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

Logging users out after certain period

LEGEND ,
Oct 11, 2006 Oct 11, 2006

Copy link to clipboard

Copied

Hi,

Im having trouble creating a basic timer that throws users out to the logout
page after a certain amount of inactivity, Its set to one minute at the
moment. I want to place this code on the top of certain pages. Im having all
sorts of trouble with the conditional code and the functions.

At the moment the page executes but my conditional code is ignored. I cant
seem to validate the client.timeout variable. I've tried the isDate
function that also hasnt worked for me. The logic is that when users request
a page the timeout variable is compared to the current time.

Can anyone help please.


<!----See if the client variable had been set from a previous load of the
page---->
<cfif isDefined("client.timeout")>

<!-----If variable isdefined calculate how long since users last
activity----->

<cfif datecompare(client.timeout, now(), n) EQ -1>
send away to logout page and kill cfid and cftoken
cookie<cfabort>
<cfelse>
keep the user active
</cfif>
</cfif>

<cfset countdown=#CreateODBCDateTime(now())#>

<cfset client.timeout= #countdown# + #CreateTimeSpan(0, 0, 1, 0)#>
<cfset client.timeout= #CreateODBCDateTime(client.timeout)#>

<!------Test Output----->
<cfoutput>#countdown#</cfoutput><br />
<cfoutput>#client.timeout#</cfoutput><br />
<cfoutput>#datediff("n", client.timeout, countdown)#
</cfoutput>


TOPICS
Advanced techniques

Views

264

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
Engaged ,
Oct 11, 2006 Oct 11, 2006

Copy link to clipboard

Copied

why don't you use session management in yuor application.cfm/cfc for this? you can set sessiontimeout parameter there.

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
LEGEND ,
Oct 11, 2006 Oct 11, 2006

Copy link to clipboard

Copied

LATEST
Yeah i was confused about that. does the sessiontimeout kill my cookies
thoughe cause oi have the following in the login page.

application.cfm page
<CFAPPLICATION NAME="xxxxx" SESSIONMANAGEMENT="YES" clientmanagement="yes"
sessiontimeout="#CreateTimeSpan(0,0,30,0)#" SETCLIENTCOOKIES="NO">


login.cfm page
<!--- CF will not set the client cookies automatically, so set them manually
as per-session cookies --->
<cfif not IsDefined("Cookie.CFID")>
<CFLOCK SCOPE="SESSION" TYPE="READONLY" TIMEOUT="5">
<CFCOOKIE NAME="CFID" VALUE="#SESSION.CFID#">
<CFCOOKIE NAME="CFTOKEN" VALUE="#SESSION.CFTOKEN#">
</CFLOCK>
</cfif>


logout.cfm page
<!---Code to delete existing session CFIF and CFTOKENS--->

<CFCOOKIE NAME="CFID" VALUE="#CFID#" EXPIRES="NOW">
<CFCOOKIE NAME="CFTOKEN" VALUE="#CFTOKEN#" EXPIRES="NOW">





"Sabaidee" <webforumsuser@macromedia.com> wrote in message
news:egk6t8$rnd$1@forums.macromedia.com...
> why don't you use session management in yuor application.cfm/cfc for this?
> you can set sessiontimeout parameter there.


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