|
|
Server Time: Friday May 9 2008 04:11 PM |
|
Your Time: |
In order to use session variables, first you have to instruct the Cold Fusion
server that you wish to use them.
<cfapplication name="PickSomeUniqueName"
ClientManagement="No"
SessionManagement="Yes"
SessionTimeout="#CreateTimeSpan(0,0,30,0)#"
SetClientCookies="Yes">It
would be best to place this inside your Application.cfm file, otherwise you will
have to add it in each of your templates before you refrence any session
variables. The "SessionTimeout" field defines how long to wait before removing
the user's session variables from the system's memory. The syntax is
SessionTimeout="days,hours,minutes,seconds". In this case, if the user does not
perform any action on your site within 30 minutes, their session variables will
dissapear.
Once you set the CFAPPLICATION tag, simply prefix any variables that you want
to be access across multiple pages with "session.". For example, once you set
the variable "session.userid", all of your pages can use it.
Keep in mind that you'll have to code in some sort of check to see if the
session variables have expired. You can either define them with a default value
or if the session variable doesn't exist, redirect them to your login page. <!--- Check to see if the session variable exists, if not set it. --->
<CFPARAM name="session.IsLoggedIn" default="N">
<!--- Check to see if the session variable exists,
if not redirect them to the login page --->
<CFIF IsDefined("session.IsLoggedIn") EQUAL "No">
<CFLOCATION URL="/login.cfm">
</CFIF>
Looking for more ColdFusion tutorials? Visit my ColdFusion Tips & Tricks website!
Date added: Tue. September 17, 2002
Posted by: John Bartlett | Views: 54709 | Tested Platforms: CF5 | Difficulty: Beginner
Best Practices
kill session
i need you help in how to kill session .. i need it in my senior project.
Posted by: reham
Posted on: 05/25/2005 02:11 AM
|
Clearing a session
http://www.cflib.org/udf.cfm?ID=1097
Posted by: John Bartlett
Posted on: 05/25/2005 02:31 AM
|
is session end?
i want to kill session when my browser closed, i do not know how to do it. need help please
Posted by: zaza
Posted on: 07/10/2006 03:00 AM
|
|
|
|
|
|
|
|