Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Session variables 1

Status
Not open for further replies.

iao

Programmer
Feb 23, 2001
111
US
I have a website where the user selects a project from a list. When they select the item and move to the next page, this item is stored as a session variable. I did this because the user must go through a series of pages that reference this selected project so I figured a session variable would be the way to go.

However, when they go back to this initial page, I need to have that session variable removed for a variety of reasons.

What is the best way to do this?
 
Hey Iao,

I don't believe there is any way to delete a single session variable so the best approach imo is to just put a <cfset session.varName=&quot;&quot;> at the top of the page. This will ensure that their choice is set (or reset) to nothing every time the visitor visits the page. You can then test to see if the session variable is blank to determine if the have made a selection.

You will probably also want to put a regular html meta tag at the top to tell the browser not to cache the page. This will make sure they reload the script if they click their back button.

<cfset session.varName=&quot;&quot;>
<META HTTP-EQUIV=&quot;Pragma&quot; CONTENT=&quot;no-cache&quot;>

Hope this helps,
GJ
 
StructDelete removes the specified item from the specified structure.

Example:
<cfscript>structdelete(Session, &quot;fieldName&quot;);<cfscript>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top