View comments | RSS feed

onSessionStart

Description

Runs when a session starts.

Syntax

<cffunction name="onSessionStart" returnType="void">
   ...
</cffunction>

See also

onSessionEnd, Method summary, Managing sessions in Application.cfc in ColdFusion MX Developer's Guide

Returns

This method does not return a value; do not use the cfreturn tag.

Usage

This method is useful for initializing Session scope data, such as a shopping cart, or setting session-specific Application scope variables, such as for tracking the number of active sessions. You never need to lock the Session scope to set its variables using this method.

If you call this method explicitly, ColdFusion does not start a session; it does execute the method code, but does not lock the Session scope.

This method can access the requested page's Variables scope only if the Application.cfc file includes an onRequest method that calls the page.

Example

The following onSessionStart example initializes some Session scope variables and increments and Application scope counter of active sessions.

<cffunction name="onSessionStart">
   <cfscript>
      Session.started = now();
      Session.shoppingCart = StructNew();
      Session.shoppingCart.items =0;
   </cfscript>
      <cflock scope="Application" timeout="5" type="Exclusive">
         <cfset Application.sessions = Application.sessions + 1>
   </cflock>
</cffunction>

ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | KnowledgeBase | Bug Reporting

Version 7

Comments


No screen name said on Sep 23, 2005 at 12:44 PM :
TYPO

Example
The following onSessionStart example initializes some Session scope variables and increments --> AN <-- Application scope counter of active sessions.
Don-R-Q said on Apr 22, 2006 at 10:13 PM :
They assumed you would follow the whole guide for Application settings, in the cfapplication example they set the Application.sessions param.

http://livedocs.macromedia.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=ColdFusion_Documentation&file=00000217.htm

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/7/htmldocs/00000702.htm